As was pointed out to me in another thread program logic can be placed into aliases. I didn't assume/know this because I really didn't think of logic "commands" as "commands" in the usual sense; i.e. in TCC "IF", "ELSE", "DO" and "ENDO" for instance are not just logic elements (as they are in most other languages), they are actually commands. So testing this out I came up with the following alias:
Unfortunately, executing this alias has the following result:
So turning the body of the above alias into a batch file:
a different error (apparently an infinite loop) but still an error.
However putting every statement on a single line:
The only "changes" were the addition of the "@Echo Off" commandand separation of the individual commands by linefeeds rather than command separator characters.
And even something like "Do 16" is not valid because "EndDo" is not valid in an alias:
So does this mean the only logic "command" allowed in an alias is the "If"?
Code:
Alias Logic=`SetLocal & Set C=0 & Set I=1 & Do While %I LT 65536 & Set /A I+=I & Set /A C+=1 & EndDo & Echo C: %C I: %I & EndLocal`
Code:
[Z:\]logic
Usage : DO [n | FOREVER]
2
1
TCC: Unknown command "EndDo"
C: 1 I: 2
[Z:\]
Code:
[Z:\]Type LogicI.btm
SetLocal & Set C=0 & Set I=1 & Do While %I LT 65536 & Set /A I+=I & Set /A C+=1 &
EndDo & Echo C: %C I: %I & EndLocal
[Z:\]LogicI
SetLocal
Set C=0
Set I=1
Do While %I LT 65536
^C
Cancel batch job Z:\LogicI.btm ? (Y/N/A) : A
[Z:\]
However putting every statement on a single line:
Code:
[Z:\]Type LogicII.btm
@Echo Off
SetLocal
Set C=0
Set I=1
Do While %I LT 65536
Set /A I+=I
Set /A C+=1
EndDo
Echo C: %C I: %I
EndLocal
[Z:\]LogicII
C: 16 I: 65536
[Z:\]
And even something like "Do 16" is not valid because "EndDo" is not valid in an alias:
Code:
[Z:\]Type LogicIII.btm
@Echo Off & SetLocal & Set C=0 & Set I=1 & Do 16 & Set /A I+=I & Set /A C+=1 & End
Do & Echo C: %C I: %I & EndLocal
[Z:\]LogicIII
TCC: Z:\LogicIII.btm [1] Unknown command "EndDo"
C: 1 I: 2
[Z:\]