reg expression and variables

Posted by Neverwhere on Wed 25 Jun 2003 08:20 AM — 6 posts, 23,419 views.

USA #0
ok. I know some about reg expressions and triggers sending to variables. Is it possible to send two unique reg expressions to two unique variables in same trigger??

Ex:
Hp:(\d*)/(\w*) Sp: (\d*)/(\w*)
%1,%3 need to be retrieved and sent to different variables.

I know i can send them to one variable, but can we split them up in scripts?
Canada #1
I think you'd need to use a script. Lets call the two variables you're using var1 and var2 (I know, I'm so clever).

sub nameofsub (a, b, c)
world.setvariable "var1", c(1)
world.setvariable "var2", c(3)
end sub


That should do it.
USA #2
what does a&b do then?
plus you cant just send directly to script, must be sent to something first (unless im missing something...)
Amended on Wed 25 Jun 2003 07:34 PM by Neverwhere
USA #3
If you have a script (in the box on the edit, a script name) you do not need to send anything anywhere.
Sub A_Sub_Routine (a, b, c)

End Sub

a is the Name of the Trigger/Alias that sent it, B is the Line (the whole thing that was matched) and C is the array of variables, thats why youll usually see them like this instead
(sName, sLine, aryWld)
Where the s's stand for String and ary is for array.

And, you COULD put the code in the Send Box, and then send to script (which gets rid of the need to make a subroutine in a seperate script file, etc etc)

world.setvariable "var1", %1
world.setvariable "var2", %3

In your send box, and then send to Script
Canada #4
Quote:
And, you COULD put the code in the Send Box, and then send to script (which gets rid of the need to make a subroutine in a seperate script file, etc etc)

world.setvariable "var1", %1
world.setvariable "var2", %3

In your send box, and then send to Script


Just out of curiosity, does anyone know if this is faster than specifying it formally in a script file?
Australia Forum Administrator #5
I think the script file would be marginally faster, because the script file is parsed once, and then the sub in it is called when needed, whereas using the "send to script" method means it must be parsed every time.

However the time difference may not be very great.