Hello Sandor,

Historians believe that Sun, 8 Jul 2001 at 21:38 GMT +0200 was when,
Sandor SZAKACS-VASS [SSV] typed the following:

SSV> I'm a new user, so it's possible that my question is a FAQ - even if I
SSV> didn't find an answer in the archives nor on the net.

Welcome.  I'll take a stab at this question.

SSV> I'm looking for some more comprehensive documentation for the macros,
SSV> because the online help is just too summary.

If you can't find the answer in the FAQ or in the Help file, then this
is the best place to ask.  BTW, the FAQ is maintained at
http://faq.thebat.dutaint.com

SSV> A general answer would be very useful, but I'll try to give a concrete
SSV> exemple beacause I think this question is somewhat blurry...

SSV> So let's take the IF macro.

You've probably chosen the hardest macro to learn.  The %IF macro was
only introduced in the last version or two.  The general macro syntax
was not designed to handle such a complex task.  However, I'll answer
your questions to the best of my ability.

SSV> The help says:
SSV> IF:"text1"sign"text2":"then text3":"else text3"
SSV> and gives the following exemple (without any further explanation):
SSV> %IF:"%TIME"<"12:00":"morning":"%IF:'%TIME'>'17:00':'evening':'afternoon'"

SSV> Well, how can I know:

SSV> - what delimiters can be used? Here we have two, I've seen another one
SSV> (space mixed with ;) in one of Chema's message...

In general, delimiters are either quotes (') or double quotes (").
However, for the %IF macro, there had to be up to 5 arguments to the
macro.  Each argument is enclosed by quotes or double quotes.  The
arguments are separated by colons (:)

SSV> - characters used as a delimiter can be quoted? Is there any mean to escape
SSV> them (like 'that\'s a quotation')?

There are two ways, in your example, you could change the outside
delimiters to double quotes, eg. "that's a quotation", or you can
double the inside quote, eg. 'that''s a quotation".  Just be careful
when using these characters within nested macros.

SSV> - can delimiters be nested? The exemple shows that ' can be used inside of
SSV> ", but what if I want to go deeper?

Yes you can.  Each time, just add another set of quotes.

The first level uses only one quotation mark:  "..."    or   '...'
The second level uses double delimiters:      ""...""   or  ''...''
The third level:                             """..."""  or '''...'''
And so on.

Since the " and ' are distinct, you can mix them within your nesting.
The only thing to remember is you can't repeat a delimiter.

SSV> - the syntax say "text", which normally should mean a string. Then we have
SSV> an exemple with dates. So what can be used? Strings, numbers, dates?

As far as I know, all numbers and dates are represented by strings in
TB macros.  So although the example appeared to use dates, the macro
was actually comparing strings.

SSV> If so, what are the rules of comparison for the strings? What are
SSV> the operators?

I'm not positive, but if I remember correctly, the operators are:
 =   - equal
 <   - less than
 >   - greater than
 <>  - not equal

If I'm wrong or incomplete, hopefully someone will correct me.

<snip>
SSV> Can I do something like:
SSV> %IF:'%SUBPATT="1"'='found':'i\'ve found it':'sorry'
SSV> This one doesn't work,

The reason this one won't work is because you're using a subpattern
inside the %IF macro without defining a regexp within that macro.
Confused?

Think of the arguments to any macro as a mini template.  It is
completely independant from the rest of your overall template.  That
means that if you want to use a regexp search, you must do the search
inside the delimiters of the %IF macro.

SSV> which is hardly suprising because the sign"text" can
SSV> be part of both macros:)

Actually it can't, but I will admit that the %IF macro's syntax leaves
a lot to be desired.  It would be much more elegant to use three (or
four) separate macros:

%IF='"text1" sign "text2"'
%THEN="text3"
%ELSE="text4"

The fourth might be a %ELSEIF macro.  For example:

%IF='"text1" sign "text2"'
%THEN="text3"
%ELSEIF='"text4" sign "text5"'
%THEN="text6"
%ELSE="text7"

SSV> Thank you in advance,

No problem.

SSV> and please don't think I'm just trying to bother you...

Nobody should think that.  Answering questions is what this list is
for.

SSV> There are too many possibilities to try-and-hope-it-will-work:)

Agreed.

SSV> a little bit frustrated because I'm unable to fully exploit
SSV> the power of the software;-P

It takes time.  :-)

-- 
Thanks for writing,
 Januk Aggarwal

Using The Bat! 1.53bis under Windows 98 4.10 Build 2222  A

Despite these words, this page is blank.

-- 
______________________________________________________
Archives   : <http://tbudl.thebat.dutaint.com>
Moderators : <mailto:[EMAIL PROTECTED]>
TBTech List: <mailto:[EMAIL PROTECTED]>
Unsubscribe: <mailto:[EMAIL PROTECTED]>

You are subscribed as : archive@jab.org


Reply via email to