Variable followed by function constantly failing...

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
May 9, 2013
40
0
#1
If I have code such as:

set message=The %ReleaseTitle% is now official.%@char[13 10 13 10]The master image is located at:%@char[13 10 9]%%ReleasedMediaFolder%%@char[13 10]The source code for this release will be archived to:%@char[13 10 9]%%ArchiveFolder.​

I seem to be getting a failure to always interpret the @char functions!

I thought - that if I have a set variable I can use a single % to indicate it, and optionally I can end it with a surrounding %, such as:

%variable
%variable%​

Either is correct, so long as the interpreter can distinguish the end of the variable. If it cannot, the second % is needed to help it out, such as:

%FirstName %LastName
%FirstName%%LastName%​

Because the whitespace makes it clear that %FristName is ending, no surrounding % is needed in the first example, but it is needed in the second because otherwise it would read:

%FirstNameLastName​

Which would not expand properly.

I thought that the same rules apply for %@functions. I thought that this worked for years?
But now I'm finding that %var%%@char[13 10] only sometimes works, and other times fails...

What is the correct rule? Is this a bug in my version of TCC? Or do I just have the rules all wrong?
 

samintz

Scott Mintz
May 20, 2008
1,229
11
Solon, OH, USA
#3
I have gotten away from using the %var% syntax because of potential parsing issues. If there is a potential for misinterpreting the variable name I use %[var].

BTW you can use ^n instead of @char[13 10] and ^t for @char[9]. So your above example becomes:
Code:
set message=The %ReleaseTitle is now official.^n^nThe master image is located at:^n^t%ReleasedMediaFolder^nThe source code for this release will be archived to:^n^t%ArchiveFolder.
 
Jan 19, 2011
561
7
Norman, OK
#6
Will this syntax help?
Code:
%[varname]
That's great! I didn't know that. I'm going to have to start doing that; I started changing the variables in BASH scripts to ${varname} a couple of years ago.