Guys, I don't really understand what the problem is here. The following works perfectly for me (TCC 13.03.48 Windows 7 [Version 6.1.7601]):
Code:
For %X in (1 a 2 b) Do (EchoS %X & If %@IsAlpha[%x] == 1 Echo Alpha! & If %@IsDigit[%X] == 1 Echo Digit!)
In case you for some reason don't completely believe me, here's the output (unmodified in any way) from the above:
Code:
1 Digit!
a Alpha!
2 Digit!
b Alpha!
I will note just to be complete that there
is an extra space between the "Echo" commands and the words "Alpha!" and "Digit!".
The original code:
Code:
echo First a FOR loop:
for %X in (1 a 2 b) do (
echos %x...
if %@isalpha[%x] == 1 echo Alpha!
if %@isdigit[%x] == 1 echo Digit!
)
Maybe I did NOT understand what The Dave was saying.
I understood that he meant that "1 a 2 b" was considered as one single line.
Instead, now it seems to me that he meant that instructions inside the for loop are handled as a single line.
Rex, can You spot some light on this?
If You consider the same code but with the for loop as one single long line You get:
Code:
echo First a FOR loop:
for %X in (1 a 2 b) do (echos %x... if %@isalpha[%x] == 1 echo Alpha! if %@isdigit[%x] == 1 echo Digit!)
So the second if is a part inside the first if.
When the variable is 1 or 2, the isaplha is not satisfied, so the echo alpha is not executed, but it is NOT executed also the second if isdigit and it is NOT executed the echo digit.
When the variable is a or b, the first if isalpha is satisfied, and so the echo alpha is executed, whereas the second isdigit is NOT satisfied and the echo digit is NOT executed.
In Your example, mathewsdw, You use the "&" separator, so I believe that You change the semantic if the command.
Regards
Rodolfo Giovanninetti