Little help please.

Posted by Metsuro on Thu 27 May 2004 09:06 PM — 11 posts, 34,927 views.

USA #0
Alright i have a 3 triggers to match a line that can vary, sometimes it has only one part, or two, or three. something like.

you see (a star|an asteroid|a comet) or
you see (a star|an asteroid|a comet),(a star|an asteroid|a comet) or even
you see (a star|an asteroid|a comet), (a star|an asteroid|a comet), and (a star|an asteroid|a comet)

what i want to do is, whenever theres a "an asteroid" to send to the mud, "stop" then set a variable Asteroids with plus one, well i would also like it to set 2 other varibles depending on what its gets, and no matter which order and such
Amended on Thu 27 May 2004 09:09 PM by Metsuro
Australia Forum Administrator #1
For one thing, you could do that with one trigger. I gather they are regular expressions? Just use the "0 or 1" quantifier, or do it with squiggly brackets, like this:



<triggers>
<trigger
custom_colour="2"
enabled="y"
match="you see (?P&lt;a&gt;a star|an asteroid|a comet)(, (?P&lt;b&gt;a star|an asteroid|a comet)){0,1}(, and (?P&lt;c&gt;a star|an asteroid|a comet)){0,1}"
regexp="y"
send_to="2"
sequence="100"
>
<send>%%0 = %0
%%1 = %1
%%2 = %2
%%3 = %3
%%4 = %4
%%5 = %5
%%6 = %6
a = %&lt;a&gt;
b = %&lt;b&gt;
c = %&lt;c&gt;
</send>
</trigger>
</triggers>


If you try this out, it will match all three cases, and by using named wildcards the three things it finds are in wildcard "a", "b", and "c".

Then you could do something like this in your (send to) script:


if "%<a>" = "an asteroid" then
  asteroids = asteroids + 1
elseif "%<a>" = "a comet" then
  comets = comets + 1
elseif "%<a>" = "a star" then
  stars = stars + 1
end if

if "%<b>" = "an asteroid" then
  asteroids = asteroids + 1
elseif "%<b>" = "a comet" then
  comets = comets + 1
elseif "%<b>" = "a star" then
  stars = stars + 1
end if
 
' ditto for c


USA #2
after adding this another of my alias, script doesn't work now wondering why

Error number: -2146827284
Event: Execution of line 1 column 5
Description: Expected ';'
Line in error:
sub OnStar(name, output, wildcs)

quick note i also get

Error number: -2146827256
Event: Execution of line 1 column 1
Description: Invalid character
Line in error:
%0 = The computer reports the presence of some debris
Called by: Immediate execution
Amended on Thu 27 May 2004 10:17 PM by Metsuro
Australia Forum Administrator #3
Which scripting language are you using? It is more normal for JScript to report a missing semicolon.

Can you post a few previous non-blank lines too? Often error messages are caused by the previous line.

Or, if that is the first line, can you paste the entire alias here? Click the "copy" button on the alias list to do it.
USA #4
Whoops accidently switched to JScript
USA #5
and are you saying to make two triggers that use

<triggers>
<trigger
custom_colour="2"
enabled="y"
match="you see (?P&lt;a&gt;a star|an asteroid|a comet)(, (?P&lt;b&gt;a star|an asteroid|a comet)){0,1}(, and (?P&lt;c&gt;a star|an asteroid|a comet)){0,1}"
regexp="y"
send_to="2"
sequence="100"
>
<send>%%0 = %0
%%1 = %1
%%2 = %2
%%3 = %3
%%4 = %4
%%5 = %5
%%6 = %6
a = %&lt;a&gt;
b = %&lt;b&gt;
c = %&lt;c&gt;
</send>
</trigger>
</triggers>

but one to the output, and the other with the other information?
Australia Forum Administrator #6
No, that was just an example. Use that trigger, but replace the "send" text (which was just to debug the trigger) with the script example I gave.
USA #7
any way to set it up to check for the comma befor and? it sometimes does not use it
Australia Forum Administrator #8
Sure. Read the regular expression write-up, they help with this sort of stuff.

Remembering I had it set up so a whole phrase was optional, certainly a comma can be optional.

Simply putting in:

,?

Means zero or one comma. Or, using the method I had above, you could say:

,{0,1}

That still says "zero to one of the preceding thing". In this example the "preceding thing" is the comma symbol.

Or, you can have groups, eg.

(, ){0,1}

That is, zero or one of a comma followed by a space.

You can do all sorts of things like that. eg.

a{5,6}

Means 5 or 6 lots of "a", ie. "aaaaa" or "aaaaaa".

Or, this:

(nick){2,3}

This would be 2 or 3 lots of "nick", ie. "nicknick" or "nicknicknick".
Amended on Fri 28 May 2004 07:11 AM by Nick Gammon
#9
as we're on this "little help" subject, I need a little help myself, how do you make a timer expand variables?
-thanks
Australia Forum Administrator #10
At present timers cannot expand variables directly, although I will look at adding that. However you could do it with "send to script" and something like this:

Send "eat " & GetVariable ("foodtype")