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

Another "What is wrong?"

Discussion in 'Support' started by mathewsdw, Sep 2, 2015.

  1. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Behold the following:
    Code:
    TCC: Z:\BuildFlatSongNames.btm [24]  Variable loop
    Z:\BuildFlatSongNames.btm [24]  Usage : IF [/I] [NOT] condition [.AND. | .OR. | .XOR. [NOT] condition ...] command
    
    And the line(s) in question:
    Code:
    23  If NOT EXIST "F:\Full\%BaseName; %Artist; %@Field["\",-1,%Name].%@Ext[%Name]" ^
    24     MkLink /H "F:\Full\%BaseName; %Artist; %@Field["\",-1,%Name].%@Ext[%Name]" %Song
    
    If there's something wrong there (and I am assuming that there is) I'm certainly not seeing it.
     
  2. Rodolfo

    Joined:
    May 20, 2009
    Messages:
    213
    Likes Received:
    0
    You might want to check the exact values of these variables.
    If it is inside a loop, just for test, You might add lines such as "echo BaseName = %BaseName" and then a "pause" command.
    Also, if %Name is the complete name of a file (You use %@Ext[%Name] to get the extension), then I believe that to get the base name You should use %@Field["\",-0,%Name] and not %@Field["\",-1,%Name].
    But, I am not sure, I do not know what are the values of these variables.


    Regards

    Rodolfo Giovanninetti
     
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,809
    Likes Received:
    82
    TCC returns the variable loop error message when you have variables defined inside variables. The variable expansion parser will go 15 levels deep trying to (recursively) expand a variable name, but if you have something like variable a contains variable b which contains variable a, you'll get the loop error.
     
  4. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    First a note. I asked initially asked this question quite a while ago but I got involved in other tasks and just got back to it today.

    Rex, I understood that. However I don't see any way I have a variable name inside of a variable. Here's the whole BTM file:
    Code:
      1 @Echo Off
      2 SetLocal
      3 For /R F:\Music %FileName in (*) Do (
      4  Gosub DoIt "%FileName"
      5 )
      6 EndLocal
      7 Quit 0
      8 :DoIt [Song]
      9  Set Name=%@Unquote[%Song]
      10  Set BaseName=%@Name[%Song]
      11  If %@IsDigit[%@Left[2,%BaseName]] == 1 .AND. "%@Instr[3,3.%BaseName]" == " - " ^
      12  Set BaseName=%@Right[-5,%BaseName] (%@Left[2,%BaseName])
      13  Iff "%@Field["\",-1,%Name]" == "Disc " Then
      14  Set Artist=%@Field["\",-3,%Name]
      15  If "%@Right[5,%Artist]" == ", The" ^
      16  Set Artist=The %@Left[-5,%Artist]
      17  If NOT EXIST "F:\Full\%BaseName; %Artist; %@Field["\",-2,%Name].%@Ext[%Name]" ^
      18  Echo MkLink /H "F:\Full\%BaseName; %Artist; %@Field["\",-2,%Name].%@Ext[%Name]" %Song
      19  Else
      20  Set Artist=%@Field["\",-2,%Name]
      21  If "%@Right[5,%Artist]" == ", The" ^
      22  Set Artist=The %@Left[-5,%Artist]
      23  If NOT EXIST "F:\Full\%BaseName; %Artist; %@Field["\",-1,%Name].%@Ext[%Name]" ^
      24  Echo MkLink /H "F:\Full\%BaseName; %Artist; %@Field["\",-1,%Name].%@Ext[%Name]" %Song
      25  EndIff
      26 Return
    
    I will note that line 24 (the line that is reported as being in error) is in the command that is executed if the condition evaluates to "True". but I will add that that might be just a result of the "If" command spanning two lines.
     
  5. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,288
    Likes Received:
    39
    As Rodolfo suggests, it would be a good idea to echo the values of critical variables -- in particular %NAME and %BASENAME -- to figure out which file is causing this error.

    I wouldn't be surprised if the filename in question contains percent signs. That's not uncommon in files downloaded from the internet with a browser.
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
    What's the error message from line 24? It's pretty hard to get an error message from an ECHO command.
     
  7. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,288
    Likes Received:
    39
    Pretty sure the "Variable loop" error happens during variable expansion, before the actual command is executed.
     
  8. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    This line
    Code:
      11  If %@IsDigit[%@Left[2,%BaseName]] == 1 .AND. "%@Instr[3,3.%BaseName]" == " - " ^
    looks wrong to me. There should be a comma instead of a period after the second '3' in @instr.
     
  9. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Thank you Dave, you hit the problem on the nose! That should have been a comma instead of a period. Bad typing made the error; bad eyesight made it hard for me to see it. However that doesn't explain either the error message or the line that was said to be in error, but it's all water under the bridge now.
     

Share This Page