Welcome!

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

SignUp Now!

Another "What is wrong?"

May
855
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.
 
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
 
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.
 
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.
 
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.
 
What's the error message from line 24? It's pretty hard to get an error message from an ECHO command.
 
What's the error message from line 24? It's pretty hard to get an error message from an ECHO command.

Pretty sure the "Variable loop" error happens during variable expansion, before the actual command is executed.
 
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.
 
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.
 

Similar threads

Back
Top