First, just so there's no mistake, the following is a very simple and somewhat contrived batch file (named "Sample.btm") to illustrate the issue without dealing with a number of side issues that are completely irrelevant.
And here are the (annotated) results of running the above batch file:
This issue as you can hopefully readily see is that the "Return" within the "true" clause of the "Iff" statement within the "Do While" generated an error. Is this the way that it is supposed to work? Is this documented if it is? Is so, where? (Yes, it's got an easy workaround. But I'd still like to understand what is going on here.)
And on the subject of "what is going on here?", just out of curiosity what's with the "@28" returned by "InKey" when a carriage-return is hit? The ASCII code of a carriage return is 0x0d (decimal 13) and for a line-feed is 0x0a (decimal 10) and I can't see any relationship between either of those two values and "@28".
- Dan
Code:
@Echo Off
SetLocal
Gosub TestIt
@Echo Everything is %OK
EndLocal
Quit 0
:TestIt
Set OK=
Set Result=%@Char[1]
Set Again=Please
Do While "%OK" == ""
@Echo %Again hit any key or hit ENTER to just forget it... >CON:
InKey /C /X /W5 %%Result
Set Again=Again, please
Iff "%Result" == "@28" Then
Set OK=Not OK!
Return
ElseIff "%Result" != "%@Char[1]" Then
@Echo `` >CON:
Set OK=OK
EndIff
EndDo
Return
Code:
Sun Apr 29, 2012 10:35:24a
ISO8601 plugin v1.2.3 loaded.
SafeChars plugin v1.6.4 loaded.
TCC 13.04.61 Windows 7 [Version 6.1.7601]
Copyright 2012 JP Software Inc. All Rights Reserved
Registered to Daniel Mathews
[Z:\]:: I will let it time-out three times and then hit a key that's not ENTER...
[Z:\]Sample
Please hit any key or hit ENTER to just forget it...
Again, please hit any key or hit ENTER to just forget it...
Again, please hit any key or hit ENTER to just forget it...
a
Everything is OK
[Z:\]:: This time I will let it time-out twice and then hit ENTER...
[Z:\]Sample
Please hit any key or hit ENTER to just forget it...
Again, please hit any key or hit ENTER to just forget it...
TCC: Z:\Sample.btm [23] Missing GOSUB
Everything is Not OK!
[Z:\]
And on the subject of "what is going on here?", just out of curiosity what's with the "@28" returned by "InKey" when a carriage-return is hit? The ASCII code of a carriage return is 0x0d (decimal 13) and for a line-feed is 0x0a (decimal 10) and I can't see any relationship between either of those two values and "@28".
- Dan