1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WAD Variable name gets changed within FOR loop

Discussion in 'Support' started by nickles, Jun 21, 2013.

  1. nickles

    Jun 24, 2008
    Likes Received:
    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

    Attached Files:

    • x.btm
      File size:
      190 bytes
    • 002.png
      File size:
      119.4 KB
  2. Steve Fabian

    May 20, 2008
    Likes Received:
    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.
  3. rconn

    rconn Administrator
    Staff Member

    May 14, 2008
    Likes Received:

    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.

Share This Page