Another "What is wrong?"

#1
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.
 
May 20, 2009
232
1
54
ITALY
#2
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.
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
 

rconn

Administrator
Staff member
May 14, 2008
10,494
94
#3
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
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
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.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,570
46
Albuquerque, NM
prospero.unm.edu
#5
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.
 
May 29, 2008
529
3
Groton, CT
#8
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
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.