Re: Is there a precise description for macros? (the story of %IF)

2001-07-10 Thread Sandor SZAKACS-VASS

On Mon, 9 Jul 2001 15:26:51 -0700
Januk Aggarwal <[EMAIL PROTECTED]> wrote:

> SSV> say higher level or general) macros like %LANGUAGE or %SINGLERE
> SSV> can't be used inside of a quick template included by an %IF
> As far as I know, it should work.  You might want to check that there
> are no typos anywhere.  Also, inside the quick template, the nesting

You're right, it works. I can't retrace the problem but I assume I forgot
the quotation marks for the second string, because today I did the same
mistake and the result was similar.

But there is a positive side in everything:) Try this:
%IF:"string"="astringa":"matches":"does not match"

Of course, the result is "does not match". Now try this one:
%IF:"string"=astringa:"matches":"does not match"

Surprise (at least for me): it "matches". The first character after the =
sign (the 'a') was interpreted as a string delimiter, and the rest of the
line is considered as a string until another 'a' is not found. Which means
that any (?) character can be used as a string delimiter, not only " and '.

See you, Sandor who's trying to figure out what kind of regexp to use to say
"I want to match any string which contains 'domain' and is not precedeed
_somewhere_ by 'user'". So username@domain should not match, but
othername@domain should, and a lookbehind conditional subpattern can't be
used because it works only with fixed length:(
-- 
__
Archives   : 
Moderators : 
TBTech List: 
Unsubscribe: 

You are subscribed as : archive@jab.org





Re: Is there a precise description for macros? (the story of %IF)

2001-07-09 Thread Januk Aggarwal

Hello Sandor,

Historians believe that Mon, 9 Jul 2001 at 23:02 GMT +0200 was when,
Sandor SZAKACS-VASS [SSV] typed the following:

>> 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> You answer my new questions before I could ask them:) I'd no idea why my
SSV> %SETPATTREGEXP...
SSV> %REGEXPBLINDMATCH...
SSV> %IF:"%SUBPATT...
SSV> (which I used beacause it's more readable) didn't work...

Yes, it would be nice if we could create user defined global
variables.  But I'm guessing this would have to wait until TB has a
proper scripting language.  For now you can put your regexp in a quick
template and just use a %QINCLUDE in your %IF macro.

Also, the %- macro was introduced to help with the readibility issue.
It has two functions depending on where in the template it exists.  At
the end of a line, the %- macro suppresses the line-break.  In the
middle of a line, it is just a place holder.

Let me know if you want an example.

SSV> But I still have a question for today. I noticed that some (let's
SSV> say higher level or general) macros like %LANGUAGE or %SINGLERE
SSV> can't be used inside of a quick template included by an %IF
SSV> macro.

As far as I know, it should work.  You might want to check that there
are no typos anywhere.  Also, inside the quick template, the nesting
levels are reset, so you start from level 1 again.

SSV> So this won't work:
SSV> %IF:"string1"="string2":"%QINCLUDE=""English""":"%QUINCLUDE=""French"""

You have one spelling mistake: %QUINCLUDE=""French"" should be
   %QINCLUDE=""French""

SSV> where English is a quick template which contains %LANGUAGE="AM"

That looks right to me.

SSV> But this will:
SSV> 
%IF:"string1"="string2":"%LANGUAGE=""AM""%QINCLUDE=""English""":"%QUINCLUDE=""French"""

Hmm, the other one should work.  What happens if you add some text to
your English Quick Template?  Does it show up in either case?

SSV> Is there a general rule which macros can't be included this way
SSV> and in which situation (and why)?

As far as I know, you're not doing anything forbidden.

SSV> Wait a minute... Is this because what you said about macro as a
SSV> mini-template? But if so, why did it screw up the result instead of being
SSV> silenty ignored (or having effect only inside of the included template)?

I think I over-simplified the situation.  The stuff about
mini-templates is really only applicable to the regular expression
macros and other content altering macros.  The option setting macros
are treated differently.

SSV> Well, I already am a 3-days-user:))

You're doing great.

-- 
Thanks for writing,
 Januk Aggarwal

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

Is it OK to use the AM radio after noon?

-- 
__
Archives   : 
Moderators : 
TBTech List: 
Unsubscribe: 

You are subscribed as : archive@jab.org





Re: Is there a precise description for macros? (the story of %IF)

2001-07-09 Thread Sandor SZAKACS-VASS

On Sun, 8 Jul 2001 21:41:01 -0700
Januk Aggarwal <[EMAIL PROTECTED]> wrote:

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

Thank you (and the others) for your quick and very accurate answer!

> http://faq.thebat.dutaint.com

Yes, and I'm happy to report that it works with Netscape 4.7 (yesterday I
tried with Opera and Mozilla, no success):)

> SSV> So let's take the IF macro.
> You've probably chosen the hardest macro to learn.  The %IF macro was

Maybe, but it's also very useful...

> 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

So this is the reason for the rather strange syntax. I thought it was a kind
of discrepancy between usual programming-language logic and the authors' own
one.

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

Yes, after a couple of hours spent by browsing the beta-list archives (the
search engine can't deal with the % sign [nor can the FAQ's one]), I've
found a similar thread which suggested this aspect:
http://www.mail-archive.com/tbbeta@thebat.dutaint.com/msg12266.html ...wrote
by you:)

> 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.

You answer my new questions before I could ask them:) I'd no idea why my
%SETPATTREGEXP...
%REGEXPBLINDMATCH...
%IF:"%SUBPATT...
(which I used beacause it's more readable) didn't work...

But I still have a question for today. I noticed that some (let's say higher
level or general) macros like %LANGUAGE or %SINGLERE can't be used inside of
a quick template included by an %IF macro. So this won't work:
%IF:"string1"="string2":"%QINCLUDE=""English""":"%QUINCLUDE=""French"""
where English is a quick template which contains %LANGUAGE="AM"

But this will:
%IF:"string1"="string2":"%LANGUAGE=""AM""%QINCLUDE=""English""":"%QUINCLUDE=""French"""

Is there a general rule which macros can't be included this way and in which
situation (and why)?

Wait a minute... Is this because what you said about macro as a
mini-template? But if so, why did it screw up the result instead of being
silenty ignored (or having effect only inside of the included template)?

> SSV> a little bit frustrated because I'm unable to fully exploit
> SSV> the power of the software;-P
> It takes time.  :-)

Well, I already am a 3-days-user:))

See you, Sandor; a grateful user who thinks that even if the on-line help
will be ameliorated, it will hardly beat this list.
-- 
__
Archives   : 
Moderators : 
TBTech List: 
Unsubscribe: 

You are subscribed as : archive@jab.org





Re: Is there a precise description for macros? (the story of %IF)

2001-07-09 Thread Marck D Pearlstone

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Sandor,

On 08 July 2001 at  21:38:38 +0200 (which was 20:38 where I live)
Sandor SZAKACS-VASS wrote to [EMAIL PROTECTED] and made these
points:

SSV> So let's take the IF macro. The help says:



The definition has been reworked for the next release of the help and
now says:

 %IF : "var1"  "var2" :  : 

 Conditional text template insertion macro which works as
 follows:

  may be '=', '>', '<' or '<>'
 If  is = or > or < or <> (unequal) , then use the  result.
 If the compare fails, then use the  result.

 Example:
 %IF:"%TIME"<"12:00":"morning":%-"%IF:'%TIME'>'17:00':'evening':'afternoon'"
 Note that any of the , ,  or  elements may
 be either macros or text strings and macros may be used recursively
 as well.

I think this makes the working of the %IF macro a little clearer but
doesn't answer all of your questions.

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

Yeah - that puzzled the heck out of me! Until I saw that I had thought
that only colons (:) could be used.

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

The only way to escape them is by doubling them up as Januk has
described.

- --
Cheers -- .\\arck D. Pearlstone -- List moderator and fellow end user
 ~~~
\ BrainStorm - free thinking - www: http://www.brainstormsw.com /
 \ PGP Key ID: 0x929DCDA0  |  www: http://www.silverstones.com /

SB! v1.53d/iKey1000 55238-48F0B on Windows NT 5.0.2195 Service Pack 1
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (MingW32)
Comment: GPG Sealed for freshness

iD8DBQE7SXnVOeQkq5KdzaARAsKqAKC5V7d7e0dTR7w3mtMrcY4DqDcv6QCgrgv3
YK+oFjZJUJ81yCC35KkxZ+k=
=5ItD
-END PGP SIGNATURE-

-- 
__
Archives   : 
Moderators : 
TBTech List: 
Unsubscribe: 

You are subscribed as : archive@jab.org





Re: Is there a precise description for macros? (the story of %IF)

2001-07-09 Thread Thomas F

Hi Januk,

On Mon, 9 Jul 2001 00:58:24 -0700GMT (09/07/2001, 15:58 +0800GMT),
Januk Aggarwal wrote:

TF>>  %Wrapped="%Cookies="file.txt"" (won't work)
TF>> ^^

JA> Yes, that's what I said.  From your example, there are four correct
JA> options:

JA> No single quotes
JA>%Wrapped="%Cookie=""file.txt"""

Ah-so deska. Sorry, I thought you meant the "(won't work)" example
should work. So I did misunderstand what you said, and you were
correct all along. ;-)

-- 

Cheers,
Thomas.

Moderator der deutschen The Bat! Beginner Liste. Anmeldung unter:
[EMAIL PROTECTED]  

Message reply created with The Bat! 1.53d
under Chinese Windows 98 4.10 Build 1998  
on a Pentium II/350 MHz.

-- 
__
Archives   : 
Moderators : 
TBTech List: 
Unsubscribe: 

You are subscribed as : archive@jab.org





Re: Is there a precise description for macros? (the story of %IF)

2001-07-09 Thread Januk Aggarwal

Hello Thomas,

Historians believe that Mon, 9 Jul 2001 at 15:24 GMT +0800 was when,
Thomas F [TF] typed the following:

JA>> The first level uses only one quotation mark:  "..."or   '...'
JA>> The second level uses double delimiters:  ""...""   or  ''...''

TF> I hate to contradict you, but I think this is not quite correct.

I am correct, but maybe not very clear.  ;-)

TF> When you have two levels, I have noticed that it is important to
TF> use different kinds of quotation marks:

That's the point of doubling them up.  You need to make unique
delimiters for each level.

TF> ""..."" does not work, as it is interpreted as:
TF>  begin-end ... begin-end

No.  If the doubled double quotes are within a set of double quotes,
it is not interpreted the way you suggest.  See examples below.

TF> What works is this: " text 'quoted within'"

TF> Example: %Wrapped="%Cookies='file.txt'" (correct)
TF>  %Wrapped="%Cookies="file.txt"" (won't work)
TF> ^^

Yes, that's what I said.  From your example, there are four correct
options:

No single quotes
   %Wrapped="%Cookie=""file.txt"""
One set of single quotes
   %Wrapped="%Cookie='file.txt'"
   %Wrapped='%Cookie="file.txt"'
No double quotes
   %Wrapped='%Cookie=''file.txt'''

If you go to three levels, you have eight ways of doing the
delimiters.

No single quotes
   %WRAPPED="%ABtoMEMO=""%COOKIE="""file.txt""
One set of single quotes
   %WRAPPED="%ABtoMEMO=""%COOKIE='file.txt'"""
   %WRAPPED="%ABtoMEMO='%COOKIE=""file.txt""'"
   %WRAPPED='%ABtoMEMO="%COOKIE=""file.txt"""'
One set of double quotes
   %WRAPPED='%ABtoMEMO=''%COOKIE="file.txt"'''
   %WRAPPED='%ABtoMEMO="%COOKIE=''file.txt''"'
   %WRAPPED="%ABtoMEMO='%COOKIE=''file.txt'''"
No double quotes
   %WRAPPED='%ABtoMEMO=''%COOKIE='''file.txt''

-- 
Thanks for writing,
 Januk Aggarwal

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

Ok, who is General Relativity, and what did he do with Sir Newton?

-- 
__
Archives   : 
Moderators : 
TBTech List: 
Unsubscribe: 

You are subscribed as : archive@jab.org





Re: Is there a precise description for macros? (the story of %IF)

2001-07-09 Thread Thomas F

Hi Januk,

On Sun, 8 Jul 2001 21:41:01 -0700GMT (09/07/2001, 12:41 +0800GMT),
Januk Aggarwal wrote:

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

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

JA> The first level uses only one quotation mark:  "..."or   '...'
JA> The second level uses double delimiters:  ""...""   or  ''...''

I hate to contradict you, but I think this is not quite correct. When
you have two levels, I have noticed that it is important to use
different kinds of quotation marks:

""..."" does not work, as it is interpreted as:
 begin-end ... begin-end

What works is this: " text 'quoted within'"

Example: %Wrapped="%Cookies='file.txt'" (correct)
 %Wrapped="%Cookies="file.txt"" (won't work)
^^

The example shows whether I understood the question right.

-- 

Cheers,
Thomas.

Moderator der deutschen The Bat! Beginner Liste. Anmeldung unter:
[EMAIL PROTECTED]  

Message reply created with The Bat! 1.53d
under Chinese Windows 98 4.10 Build 1998  
on a Pentium II/350 MHz.

-- 
__
Archives   : 
Moderators : 
TBTech List: 
Unsubscribe: 

You are subscribed as : archive@jab.org





Re: Is there a precise description for macros? (the story of %IF)

2001-07-08 Thread Januk Aggarwal

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.


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   A

Despite these words, this page is blank.

-- 
__
Archives   : 
Moderators : 
TBTech List: 
Unsubscribe: 

You are subscribed as : archive@jab.org