Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

WAD Variable name gets changed within FOR loop

Jun
223
0
The attached batch file (x.btm) shows the attached PNG file's (002.png) results. System: Windows 7 64 bit, TCC 15.01.51.

The variable's (%arc%) name gets changed within the loop round-robin-wise. I know, it's the ")" within the password, but: no warning message ("wrong syntax
 

Attachments

  • x.btm
    190 bytes · Views: 244
  • 002.png
    002.png
    119.4 KB · Views: 277
Issue exists in TCC32 12.01.50 under WinXP, too.
Apparently the closing parenthesis of a group has higher priority in the parser than quotation marks. I tried to enclose the line from rar to the closing quote in back-quotes, which resulted in syntax error.
The simplest work-around is the use of DO/ENDDO; works without any other change. However, I suspect the ECHO in the COPY, RAR and DEL commands is for debugging, not part of the working code, and I use 7z for compression, so I did not test that way.
I had to convert the attached form of X.BTM from Unix to MS format - my editor requires CR/LF, not NL. Also, for testing or support a simpler example (e.g., no regex) is sufficient.
 
The attached batch file (x.btm) shows the attached PNG file's (002.png) results. System: Windows 7 64 bit, TCC 15.01.51.

The variable's (%arc%) name gets changed within the loop round-robin-wise. I know, it's the ")" within the password, but: no warning message ("wrong syntax


This doesn't have anything to do with FOR (FOR just makes it more obvious). The problem is with the command group parsing, which doesn't consider a quoted right paren to be "protected". This results in some of the variables in the command group being expanded before the remainder of the variables get expanded as each command in the group is executed.

The simple solution is not to use FOR (a thoroughly dreadful command, which exists solely for CMD compatibility). DO does everything far, far better. The more complicated solution is for me to break existing syntax for the sake of handling quoted )'s, which I'm reluctant to do without knowing how far-ranging an impact it will have.
 

Similar threads

Back
Top