lundi 18 mai 2015

Batch File - Error in FOR / IF statement with numbers and text

These code was working before. I added some additional letters to the "FOR" line and now it's not working.

Goal: Get user input. Set input as the "SELECTION".

:choice1
A. 1-12
B. 1-7
   1.  stuff
   2.  more stuff
   etc to 7
C.  8-10
   8.
    etc to 10
D.  11-12
  11....
  12...

SET /P c= Make a selection or eXit (X)...
CLS
IF /i %c%==X GOTO choice1
IF %A%==1 FOR %%I IN (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 A B C D) DO (
    IF /i #%c%==#%%I SET SELECTION=%c%
    EXIT /B
    )

IF %A%==2 FOR %%I IN (1 2 3 4 5 6 7 8 9 10 13 A B C D) DO (
    IF /i #%c%==#%%I SET SELECTION=%c%
    EXIT /B
    )

It is not setting SELECTION = %c% on true. I assume that is not returning TRUE when it should. This was working before. I don't understand what changed. The original line of code was:

IF %A%==1 FOR %%I IN (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 E) DO IF /i #%c%==#%%I SET SELECTION=%c% & EXIT /B

Aucun commentaire:

Enregistrer un commentaire