VOGONS

Common searches


First post, by OptimalDesigns

User metadata
Rank Newbie
Rank
Newbie

What is wrong with the following statement?

%1 is set to 'beam'

if %1x==x (call ..\GetName.bat) else set name=%1
if %1x==x (call ..\GetName.bat) else (set name=%1)
...
@echo on, shows 'set name=%1' cmd NOT activated, why in either 'if' statement. 🙁

Phil

Reply 2 of 3, by OptimalDesigns

User metadata
Rank Newbie
Rank
Newbie

But that does NOT answer my question on how or does the if ... else ... stmt. works. Here is a large example that does NOT show any ECHO responses, why?

 if %FCext%X == fcX  (
echo getName.bat ok 1
) else if %FCext%X == expX (
echo getName.bat ok 2
) else if %FCext%X == exeX (
echo getName.bat ok 3
) else (
if %FCext%X == forX (
echo getName.bat ok 4
) else (
echo Wrong FileType ... must be FC, FOR, EXP, or EXE
echo.
pause
rem exit
)
echo getName.bat ... ENDing!!!

When testing (so far) %FCext% = fc and no "getName.bat ok 1" msg is produced, why? Nor does the "getName.bat ... ENDing!!!" msg show. But it EXITs my bat file (w/o a PAUSE!) How is that possible!?!? What's wrong with my code OR PC?

UPDATE: Got the above code working! Thanks, Phil

Thanks, Phil

Reply 3 of 3, by Synoptic

User metadata
Rank Member
Rank
Member

I don't know if it's the _SPACE_ char before and after the comparator, but anyway, this works :

@echo off
echo %FCext%X

if /I %FCext%X==fcX (
echo getName.bat ok 1) ELSE ( if /I %FCext%X==expX (
echo getName.bat ok 2) ELSE ( if /I %FCext%X==exeX (
echo getName.bat ok 3) ELSE ( if /I %FCext%X==forX (
echo getName.bat ok 4) ELSE echo Wrong FileType ... must be FC, FOR, EXP, or EXE)))