Hello Avenarius,
Historians believe that Sunday, July 29, 2001 at 09:05 GMT +0200 was
when, Avenarius [A] typed the following:
<snip>
A> %IF:'%DOW'='Sunday':'Enjoy your Sunday!':'%-
A> %IF:''%DOW''=''Saturday'':''Enjoy your Saturday!'':''%-
A> %IF:'''%DOW'''='''Friday''':'''Enjoy your weekend!''':'''%-
A> Take care!'''%-''%-'
A>
A> %DOW
A>
A> And the output?
A>
A> Enjoy your Sunday!Sunday'''='''Friday''':'''Enjoy your weekend!''':'''Take
care!''''''
A>
A> Sunday
A>
A> What's going on here?
For some reason, the ''' in line three is being taken to be closing
the double and single delimiter. This definitely looks like a buglet.
There is a workaround to get upto 4 conditions:
%IF:'%DOW'='Sunday':'Enjoy your Sunday!':'%-
%IF:''%DOW''=''Saturday'':''Enjoy your Saturday!'':''%-
%IF:"%DOW"="Friday":"Enjoy your weekend!":"%-
Take care!"%-''%-'
<snip>
A> Also, the exponential growth of quotation marks as more
A> conditions are added to the %IF macro (even if it did work as
A> expected) threatens to get out of hand.
Yup, that's why I didn't use them for the translation tables in that
other template.
To me, the best solution is to break up the %IF macro into something
like:
%IF:"string1"op"string2"
%THEN="then_string"
%ELSE="else_string"
The %ELSE macro could have a counterpart:
%ELSEIF:"string3"op"string4"
Your example above could become:
%IF:"%DOW"="Sunday"%-
%THEN="Have a good Sunday!"%-
%ELSEIF:"%DOW"="Saturday"%-
%THEN="Have a good Saturday!"%-
%ELSEIF:"%DOW"="Friday"%-
%THEN="Have a good weekend!"%-
%ELSE="Take care!"
This avoids the quotation mark glut problem and looks neater.
We're not reinventing the wheel here. We already have macros that
work this way: consider the %SETPATTREGEXP, %REGEXP[blind]MATCH and
%SUBPATT macros.
A> Still,
A> even what we have today has already managed to produce
A> magnificent results.
True, it is much better than what we used to have.
--
Thanks for writing,
Januk Aggarwal
Using The Bat! 1.54 Beta/4 under Windows 98 4.10 Build 2222 A
Personal Plan: To avoid sanity, lucidity and wit at all costs.
--
______________________________________________________
Archives : <http://tbtech.thebat.dutaint.com>
Moderators : <mailto:[EMAIL PROTECTED]>
Unsubscribe: <mailto:[EMAIL PROTECTED]>