Why does this batch file give me 'unknown command "else"' error?

Jun 3, 2008
121
1
Temecula, CA
I've created a batch file that has evolved over the years. The beginning part of the batch file's purpose is to look at the command line argument, if supplied, and then take a step based on the value. (It will require reading the header of the batch file to understand what I'm about to discuss further.)

If I invoke the batch file with no arguments, with /i, /mi or /q, the flow works properly, and it does what I want. If I use the /v=3.4.29.1 (or any other version number), which is the part I recently added, it seems to get confused on the 'iff'/'elseiff'/'endiff' sets, and eventually comes to the 'else' on line 79, which should match up with the 'iff' on line 45.

TCC: C:\Utils\ISBuild.btm [79] Unknown command "else"

Any help on figuring out how to track this down? I've hand-drawn the matches and can't find any problems, and I've also run it under the debugger, to no avail. I doubt there is a problem with the user functions and other user batch files called, because I haven't changed them in several years, and I've also used 'call' in front of the batch files for safety. If you need to see the function definitions, I can provide them.

I'm using TCC 16.03.55 x64 Windows 7 [Version 6.1.7601]

Any help provided would be greatly appreciated.
 

samintz

Scott Mintz
May 20, 2008
1,501
16
Solon, OH, USA
I am not certain, but I think that TCC treats equal signs as separators. So instead of getting a single variable whose value is "/v=3.4" you get 2 variables with values "/v" and "3.4". Could that be what's happening?
 
Jun 3, 2008
121
1
Temecula, CA
I'm not seeing your batch file.

When I've had this problem in the past, it's usually because I typed IF where I wanted IFF.

I've triple-checked all of my IFF statements and can't see anything wrong. Maybe some eagle-eye will spot something I missed.

I wish there was some better way of finding these blasted mismatches. Sometimes it's due to the program flow, but I can't even see a possibility for anything like that here.

BTW, the file should be available as an attachment. Do you not see an attachment?
 
Jun 3, 2008
121
1
Temecula, CA
I am not certain, but I think that TCC treats equal signs as separators. So instead of getting a single variable whose value is "/v=3.4" you get 2 variables with values "/v" and "3.4". Could that be what's happening?

That's a good suggestion, but my handling of the command line shouldn't care. I'll double-check it, though.
 
Jun 3, 2008
121
1
Temecula, CA
I don't have any GOTO statements. Yeah, they are really bad.

I tried to upload the file again, and now I see that something is blocking it. When I select the file and click OK, it then shows me the file symbol with the filename next to it, but stricken out. I'll try zipping it and uploading the .zip file.
 

Attachments

  • ISBuild.zip
    1.7 KB · Views: 108
Last edited:
May 20, 2008
11,388
99
Syracuse, NY, USA
This (line 62) looks a bit fishy.
Code:
if %@attrib[%_ISMFile,r] = 1
I have no idea whether it's related to the error in question
 
Line 88/89

Code:
elseiff (%1) == () .or. (%1) == (/q) .or. (%1) == (/i) then
    rem set _Build_Param="%@iniread[%@sfn[%@expand[*.ipr]],Data,CurrentMedia]"

leads to an empty elseiff branch. For testin, replace rem with echo.
 
Jun 3, 2008
121
1
Temecula, CA
This (line 62) looks a bit fishy.
Code:
if %@attrib[%_ISMFile,r] = 1
I have no idea whether it's related to the error in question

What's fishy about it? %_ISMFile is an environment variable pointing to the name of the file that I want to test. It returns either 0 or 1. Oh, and the full line is:

Code:
if %@attrib[%_ISMFile,r] = 1 echo Not modifying project version because project is read only.

That looks properly formed to me. What am I missing?
 
Jun 3, 2008
121
1
Temecula, CA
I don't understand. What's wrong with a REM inside an IFF block?

Nothing. That's a section of code that is extremely rarely used anyway, but I probably did that a long time ago for testing purposes. I've removed the REM to put the original statement back into place. Of course that's not the problem, because that section of code isn't even being exercised anyway. I'm using the part inside the iff "%@expand[*.ism]" != "" then (for building InstallShield .ism project), rarely ever the else part (for building InstallShield 5.5 project). And my problem occurs when testing with a .ism file, and only when I use the /v=1.2.3.4 switch.
 
May 20, 2008
11,388
99
Syracuse, NY, USA
How "/v=1.2.3.4" is interpreted will depend on the value of the INI directive CMDBatchDelimiters. If not specified the default is "Yes".
Code:
v:\> type test.btm
echo %%$ is %$
echo %%1 is %1
echo %%2 is %2

v:\> option cmdbatchdelimiters
cmdbatchdelimiters=No

v:\> test.btm /v=1.2.3.4
%$ is /v=1.2.3.4
%1 is /v=1.2.3.4
%2 is

v:\> option //cmdbatchdelimiters=Yes

v:\> test.btm /v=1.2.3.4
%$ is /v 1.2.3.4
%1 is /v
%2 is 1.2.3.4
 
Jun 3, 2008
121
1
Temecula, CA
How "/v=1.2.3.4" is interpreted will depend on the value of the INI directive CMDBatchDelimiters. If not specified the default is "Yes".

That may be true in a newer version, but I'm using TCC version 16.03.55, and that option doesn't exist.

However, I can state that the version number is getting passed nicely to my batch file. I'm getting the right string to use.

Just for evidence, I created your batch file. Here's the output:

Code:
->test.btm /v=1.2.3.4
%$ is /v=1.2.3.4
%1 is /v=1.2.3.4
%2 is

I appreciate the assistance each of you is providing. I remember Vince, Charles and Scott from back in the 4DOS days! :eek:
 
May 20, 2008
11,388
99
Syracuse, NY, USA
CMDBatchDelimiters exists in my version 16.03.55. Apparently it's set the way you want it.

"MickeyF" is vaguely familiar from the old days.
 
Jun 3, 2008
121
1
Temecula, CA
CMDBatchDelimiters exists in my version 16.03.55. Apparently it's set the way you want it.

"MickeyF" is vaguely familiar from the old days.

Yeah, it's been a long time since I needed assistance here. That's a good thing!

I just realized that the option name is case sensitive. I had just typed it in directly without worrying about its case. It's currently set to 'No'. Which it would appear is what I want. Anyway, as it is right now I have an ugly goto in there to skip past the trouble stuff. It's a hack, but it does work... If no one can find my bug, at least I have a workaround.
 
Similar threads
Thread starter Title Forum Replies Date
C How to? ctrl-c does not prompt "Terminate batch job" Support 2
D Parsing an array variable to an array does not work Support 5
J Take command does not start on Windows 10 Support 3
J ffind does not find files Support 4
Joe Caverly PAUSE does not erase countdown timer Support 0
D ParentDirectory does not update directory history Support 6
D Documentation Help "Startup" page does not describe global lists Support 0
Charles Dye Does HASH's /E option do anything? Support 1
fishman@panix.com First TCC instantiation after reboot does not work. Support 17
D Fixed @VERSION does not increment pre-fixed version numbers. Support 1
vefatica Why does @WSLPATH double the leading '/'? Support 7
D What does the file "..\Everything\Run history.csv" store? Support 5
Peter Murschall WAD rem does not work correctly Support 8
vefatica Does @SYMLINK work? Support 6
R Tree on FAT32 does not sort by name by default. Support 6
A Tcc does not recognize "bcdedit" Support 20
M Ctrl-C when using command line history does nothing Support 2
vefatica JOBS /K ... how does it work? Support 5
Joe Caverly Why does TCCRT return VIEW as an internal command? Support 6
D Does TCC improve CMD's implementation of ECHO? Support 6
vefatica Find Files/Text dialog: does it work? Support 0
Alpengreis [v22.00.41] sync command flag "/X" does not work Support 22
Joe Caverly .PS1 script does not work with PSHELL Support 11
M MOVE does not behaves like intended (on failure) Support 1
R Fixed Sendmail parameter /USER= does not work Support 4
twaterloo does tcc have a task sceduler Support 4
Brian Woodward How to? Does FTP.CFG only support SSL over port 21? (Newbie) Support 6
M Activation Key does not correspond… Support 2
James Miller tcc shell window does not disappear Support 18
D Lua does not work on the commandline Support 5
D Fresh instance of TCMD does not use TCMD.INI Support 7
D Fixed @Lua does not behave as documented Support 8
D everything /o does not open the option dialog Support 4
M Why does HELP keep opening in the background? Support 0
vefatica Does TCC know I'm visiting the forums? Support 76
vefatica Why does my forum theme keep changing? Support 1
fishman@panix.com 19.02.37 Does Not Install For Me Support 2
I Windows 10 console does not allow alt-F4 alias to complete Support 1
fromano WAD ver /r does not detect Win 10B10166 Support 5
Alpengreis Fixed BATCOMP /O does not work Support 1
D Fixed Cut and paste in TC's file/folder view does not remove file Support 17
E View (internal command) does nothing now Support 3
D How does Cut work? Support 8
B How to? why does my BTM stop Support 2
I "IF" command in a variable does not expand redirection variable name Support 0
samintz How to? What does ~ do? Support 1
C Msg Popup window does not close Support 8
D WAD Alt-Left doesn't work, but Alt-Shift-Left does Support 1
Joe Caverly @SCRIPT does not like all comments Support 2
R WAD Copy /w does not use recycle bin Support 7

Similar threads