Computing.Net > Forums > Disk Operating System > errorlevel question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

errorlevel question

Reply to Message Icon

Name: RAZOR
Date: June 23, 2000 at 14:09:47 Pacific
Comment:

how do you know what value to make the errorlevel when you're using the choice command in batch files?
assuming you're making a menu with say.. 9 objects, and it goes somewhere different depending on which number the person pushes
if the person pushes one, then it follows this code:
if errorlevel 1 goto wherever
and goes to "wherever"
it works with 2,3,4,5,6,7,8,9,0 I think.
what about letters? how do you know which value to set the errorlevel to if you want the person to push a letter?



Sponsored Link
Ads by Google

Response Number 1
Name: DoOMsdAY
Date: June 23, 2000 at 14:17:22 Pacific
Reply:

Example:

CHOICE/C:ABC123
IF ERRORLEVEL = 6 GOTO CHOICE3
IF ERRORLEVEL = 5 GOTO CHOICE2
IF ERRORLEVEL = 4 GOTO CHOICE1
IF ERRORLEVEL = 3 GOTO CHOICEC
IF ERRORLEVEL = 2 GOTO CHOICEB
IF ERRORLEVEL = 1 GOTO CHOICEA

If you don't handle errorlevels from the highest possible value to the lowest, then (due to the annoyances of Batch) anything less than or equal to the actual keypress will get executed. In other words, if the user presses 3 (with a value of 6) and you handle things with errorlevels from 1 to 6 (instead of 6 to 1 as in my example) then as far as Batch is concerned, ALL errorlevels are true and all would be executed. Takes a bit of getting used to. :)


0

Response Number 2
Name: RAZOR
Date: June 23, 2000 at 14:59:16 Pacific
Reply:

What about when you get to errorlevel 10?
is that possible? or does it just go errorlevel 10, 11, 12, etc..


0

Response Number 3
Name: World Library
Date: June 23, 2000 at 15:46:36 Pacific
Reply:

You may go up to 26 for letters.
Up to 9 for numbers.

If you wish to use all the keys........
well then you need to create a second party program.

To create your own scankey.com
Using notepad or a text editor.

USE YOU CAPS!!!!

N SCANCODE.COM
A 100
XOR AH, AH
INT 16
CMP AH, 0
JE 100
MOV AL, AH
MOV AH,4C
INT 21

R CX
10
W
Q

Copy and paste the above. Call it scancode.scr

Then in dos type:
Save on a floppy in A:
goto dos
type A:
enter
Then type
debug < scancode.scr
enter

File should be approx 16 bytes.

Here are the keys and their errorlevels.
Hope this shows up ok....but
Starting from the top left at the esc key and going across the key board.

ESC
01 59 60 61 62 63 64 65 66 67 86 87 88
P SCREEN SL PAUSE
[224 42 55] 70 [225 29 69]

~ INS H PU KEYPAD
41 02 03 04 05 06 07 08 09 10 11 12 13 14 89 71 73 [69 53 55 74]

TAB DEL END PD KEYPAD +
15 16 17 18 19 20 21 22 23 24 25 26 27 43 83 79 81 [71 72 73 78]

C LOCKS ENTER KEYPAD
58 30 31 32 33 34 35 36 37 38 39 40 28 75 76 77

SHIFT UP KEYPAD ENTER
42 44 45 46 47 48 49 50 51 52 53 54 72 79 80 81 28

CONTROL KEYPAD
29 56 [NO CODE FOR SPACE BAR] 56 29 75 80 77 82 83


Peace Goodwill and Happy Computing


0

Response Number 4
Name: RAZOR
Date: June 23, 2000 at 18:42:37 Pacific
Reply:

WOW! thanks a lot!!
although... how do I use the scancode.com file once it's made?


0

Response Number 5
Name: RAZOR
Date: June 23, 2000 at 18:59:27 Pacific
Reply:

World Library, since you seem to know a lot, is there any way I could have user imputs in a batch file? for example, the batch file asks the user to type their name. they do so, then press enter. then their name is used throughout the batch file for example.
in other words, can you set a variable to what somebody types in? or another exmaple, say you want a batch file to do the same thing to many different named files in a directory. well, you could get it to do it all at once, but that's no fun (just more efficient) so my batch file asks me the name of the file, and then I type it in, and it does whatever it is told to do to the file with that name.
I don't know if that makes any sense..
like with javascript. you pop up a prompt where the user types in his/her name, and then in your HTML, you can just write like.. %prompt% or something.. well, I think it's supposed to be written as "+prompt+" but you get my drift. wherever the phrase "+prompt+" appears, it fills it in with whatever the user types.
is there a way to do this with batch files?


0

Related Posts

See More



Response Number 6
Name: W0rm
Date: June 24, 2000 at 12:39:23 Pacific
Reply:

errrr, why wouldnt you just do "IF ERRORLEVEL 10" etc?


0

Response Number 7
Name: World Library
Date: June 25, 2000 at 12:05:04 Pacific
Reply:

CLS
@ECHO OFF
ECHO MENU
ECHO A B C D E F G H I ECT.
SCANKEY
IF ERRORLEVEL 64 GOTO F6
IF ERRORLEVEL 63 GOTO F5
IF ERRORLEVEL 62 GOTO F4
IF ERRORLEVEL 61 GOTO F3
IF ERRORLEVEL 60 GOTO F2
IF ERRORLEVEL 59 GOTO F1
IF ERRORLEVEL 50 GOTO M
IF ERRORLEVEL 49 GOTO N
IF ERRORLEVEL 48 GOTO B
IF ERRORLEVEL 47 GOTO V
IF ERRORLEVEL 46 GOTO C
IF ERRORLEVEL 45 GOTO X
IF ERRORLEVEL 44 GOTO Z
IF ERRORLEVEL 38 GOTO L
IF ERRORLEVEL 37 GOTO K
IF ERRORLEVEL 36 GOTO J
IF ERRORLEVEL 35 GOTO H
IF ERRORLEVEL 34 GOTO G
IF ERRORLEVEL 33 GOTO F
IF ERRORLEVEL 32 GOTO D
IF ERRORLEVEL 31 GOTO S
IF ERRORLEVEL 30 GOTO A
IF ERRORLEVEL 25 GOTO P
IF ERRORLEVEL 24 GOTO O
IF ERRORLEVEL 23 GOTO I
IF ERRORLEVEL 22 GOTO U
IF ERRORLEVEL 21 GOTO Y
IF ERRORLEVEL 20 GOTO T
IF ERRORLEVEL 19 GOTO R
IF ERRORLEVEL 18 GOTO E
IF ERRORLEVEL 17 GOTO W
IF ERRORLEVEL 16 GOTO Q
IF ERRORLEVEL 01 GOTO END1

:END1
GOTO END
:Q
:W
continue to F6 at top.....yes upside down and backwards.......

Sorry about the caps.....ouch. It is just a snipit from a bat written in caps.....
The com will work well on an older keyboard,
but slow on Microsofts un-natural keyboard.

On the other question, if you post the bat we can all help filling in the blanks.

echo Hello %2% !
echo Do you have a last name %2% ?

World Library Creedo.....

We are the last to know and the first to forget. Laughing out loud.

Raintree @ World Library

ps. I would of embedded the file into the pic below, but my site has once again been hacked and the password changed........bummer!
My isp wont be open until Tuesday for me to call and fix this again.

I just love the www............Ha!


0

Response Number 8
Name: Laurence
Date: July 9, 2000 at 00:59:02 Pacific
Reply:

For a dicussion of errorlevels and examples,
see "If errorlevel" on this page:
http://bigfoot.com/~batfiles/basic/chap26.htm

See also #66, #68 on this page
http://bigfoot.com/~batfiles/main/batchfaq.htm


0

Sponsored Link
Ads by Google
Reply to Message Icon

cd-rom drivers Dos boot disk - the great...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: errorlevel question

DOS Menus Question...Not Like Below www.computing.net/answers/dos/dos-menus-questionnot-like-below/15518.html

Dos - Errorlevel 45? www.computing.net/answers/dos/dos-errorlevel-45/7335.html

xcopy errorlevels??? www.computing.net/answers/dos/xcopy-errorlevels/7510.html