1.

Solve : Stack an user entry into a var.?

Answer»

I would like to know how to stack a user entry into a var.  Something like a choice, but that you put the "answer" of the choice directly into a var instead of USING errorlevels, because i have something like 36 possibilities and that's a lot of if errorlevel == 1 ... .  Thank you very much for help.  Or, if you have a fastest way than errorlevel == ... It would be greatly appreciated.How about explaining your application. Perhaps by posting a BAT file with magical, imaginary commands that would meet your need.

Off hand, I can't think of any way to get variables into a BAT file after it has started.

Mac
Ok, my code is long and in french (Comments) , but it looks like thats :

[...]
echo 1) Cancel
echo NB : Enter the letter of the drive you want to see
choice /n/c:1abcdefghijklmnopqrstuvwxyz Letter?
 if errorlevel == 1 dir Z:\
 [...] (All errorlevel)
 if errorlevel == 27 goto ad
REM ad is the label of the menu just before this one ...
[...]

The fact is that i would like to get the answer of the choice or if you have a code to get an entry... in a var o i could write something like :
dir %Drive%:\
My code isn't that exactly but it's HARD to explain but the better example is that...
Thank you very much...OK, I think I understand. Try running the following and see if it works.

Mac

echo off
:GetIt
echo ..............
echo Enter the letter of the drive you want to see
echo (else enter "1" to cancel)
choice /n/c:1abcdefghijklmnopqrstuvwxyz Drive:
if errorlevel 1 set Drive=1
if errorlevel 2 set Drive=A
if errorlevel 3 set Drive=B
if errorlevel 4 set Drive=C
if errorlevel 5 set Drive=D
if errorlevel 6 set Drive=E
if errorlevel 7 set Drive=F
if errorlevel 8 set Drive=G
if errorlevel 9 set Drive=H
if errorlevel 10 set Drive=I
if errorlevel 11 set Drive=J
if errorlevel 12 set Drive=K
if errorlevel 13 set Drive=L
if errorlevel 14 set Drive=M
if errorlevel 15 set Drive=N
if errorlevel 16 set Drive=O
if errorlevel 17 set Drive=P
if errorlevel 18 set Drive=Q
if errorlevel 19 set Drive=R
if errorlevel 20 set Drive=S
if errorlevel 21 set Drive=T
if errorlevel 22 set Drive=U
if errorlevel 23 set Drive=V
if errorlevel 24 set Drive=W
if errorlevel 25 set Drive=X
if errorlevel 26 set Drive=Y
if errorlevel 27 set Drive=Z
if %Drive%==1 goto Adios
if not exist %Drive%:\*.* (
echo No such drive on this computer
goto GetIt
)
dir %Drive%:\
goto GetIt
:Adios
Ok, thank you for the code, it is a little bit looking like my old one, excetion that it's more optimized...
Oh, and the if not exists %Drive%:\*.* is a good idea...  Thanks another time.What is more correct in French,

"Vous êtes bienvenu"

"DE rien"

"service"

Mac
1. Most polite (Almost unused) : BIEN à vous
2. Polite : Vous êtes LE bienvenu
3. Normal (Mostly used) : De rien
4. Normal (Less used) : Ça n'est rien...

You can use all of these ones, but the 2 first are more appropriated with elderly people or with people that you doesn't wanna know personnaly (Or if you want to be very polite)
Elsewhere, you should use 2, 3 or 4 because they are more flexible so they are kind of "joker" because you are not too polite and not not enough...  They are other but less used or polite ...



Discussion

No Comment Found