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

SignUp Now!

Variable followed by function constantly failing...

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:


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

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:


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?
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:
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.
Functions never take a trailing percent sign. The closing right bracket is all the parser needs.
Will this syntax help?
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.

Similar threads