On Mon 7 June 2004, 15:15:24 +1000, Cyrille wrote:
> At the end of the QT I omitted also the # at the end of the last code
> line.

Ah, yes I see now. I hadn't noticed that previously.

> What is this # good for?

The %If macro works like this:

%If:"var1"<comparison operator>"var2":"<action if true>":"<action if false>"

which is equivalent to

%If:"var1"<comparison operator>"var2"%-
:"<action if true>"%-
:"<action if false>"


However, if you have nested %If macros, you need to adjust the delimiters
("). So if you want to do another comparison operation if the first one
is false, you might end up with:

%If:"var1"<comparison operator>"var2"%-
:"<if true 1>"%-
:"%If:'var1'<comparison operator>'var3':'<if true 2>':'<if false 2>'"

Note that I have used one delimiter (') for the inner %If macro, and a
different one (") for the outer.

More complex macro combinations can have multiple levels of delimiters
from nested %If, regex and other macros, requiring careful choice of
delimiters. Common ones are ",',^,#,_,$ although almost any character can
be used.

Now in the QT we are referring to, there is a %if macro statement that
starts

  %If:#%_SetLang#<>##:##:#%-

It is checking to see if %_SetLang is blank, using # as the delimiter
(#%_SetLang#<>##)

If %_SetLang is blank, nothing happens because the <action if true> is blank
(##)

If %_SetLang is not blank then the rest of the QT should get executed
(the end of the <action if false> is the last # of the QT, which you
deleted). Since it was the last character in the QT, I don't think it
will cause a problem, but it would be better to have it back in.

However, it would be better to have the # before the %- to remove the
blank line that will otherwise be there.

The reason I used # as the delimiter is because within the <action if false>
I had one regex and seven %If statements all separately using " and ' as
delimiters.

==========

> What *exactly* does %-?

Put simply, it tells TB! to ignore a following new line (i.e. a blank line).
It will also mark the end of a macro if there might be ambiguity about
where the end is.

For example, above I wrote
   %If:"var1"<comparison operator>"var2"%-
   :"<action if true>"%-
   :"<action if false>"
as an alternative to having the %If statement on a single line. TB! sees
it as a single line because of the %- at the end of each line. The reason
I wrote it like that is because it is simpler to understand with the
three parts to the %If statement on three separate lines.

In addition, however, if I wanted to set the subject, from and to address
in a QT, I could put

   %subject="something"
   %from="me <[EMAIL PROTECTED]>"
   %to="you <[EMAIL PROTECTED]>"

When TB! processed that, each line would affect the headers, BUT EACH
LINE WOULD ALSO LEAVE A BLANK LINE IN THE BODY OF THE EMAIL.

That is because TB! is very literal about the way it processes the
content of QTs. If the QT contains plain text, it simply gets written to
the place it is called from (the body of your message). If it contains a
mixture of macros and plain text, the macros get executed, and the plain
text gets copied to the body of your message.

Now TB! sees all the new lines as plain text. They are not part of the
macro, so they simply get written to the body of your message. If you
don't want that, you must tell TB! to ignore the new line by putting %-
immediately before it.

So if you write
   %subject="something"%-
   %from="me <[EMAIL PROTECTED]>"%-
   %to="you <[EMAIL PROTECTED]>"%-
TB! ignores all those new lines and you don't get three blank lines in
the body of your message.

It's simple, but also confusing. I hope I have helped clear up some
confusion! ;-) <-- No smiley icon there as far as I am concerned!!

-- 
Robin Anson
Using The Bat! v2.11.02 on Windows XP 5.1 Build 2600 Service Pack 1






________________________________________________
Current version is 2.11.02 | 'Using TBUDL' information:
http://www.silverstones.com/thebat/TBUDLInfo.html

Reply via email to