Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
patryn
Apprentice


Joined: 26 Sep 2001
Posts: 124

PostPosted: Tue Jun 14, 2005 12:50 pm   

Matching large lists in one line
 
Is there any fast way of testing a line to see it matches any patterns within a list variable.

I know it's possible to do this using something like this:

#forall @ListVar {#if %pos(%i,%line) {#echo Match}}

The problem is that this is too slow. I know it's possible to test this a lot faster using a trigger such as:

#trig {@ListVar} {#echo match}

This is really very fast, probably due to zmud's trigger optimizations. What im after is something like a function version of a trigger..

like for example:
%trig("%line","@ListVar")

This would return a 1 or a 0 or somesuch, and it would do it in the same way that a trigger does the test, without looping through a #forall statement.

Is there anything like this already?
I haven't been able to include list variables in %pos or %match funcitons as yet.

Thanks.
_________________
That which does not kill us, makes us stronger.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Jun 14, 2005 10:38 pm   
 
Nope, you will simply have to use a loop of some kind. %match() would have been the exact thing you were asking for but currently it either is not designed to handle stringlist patterns or there's a bug preventing such.
_________________
EDIT: I didn't like my old signature
Reply with quote
patryn
Apprentice


Joined: 26 Sep 2001
Posts: 124

PostPosted: Tue Jun 14, 2005 11:33 pm   
 
Ah. It's interesting how everytime I post on here I seem to realise a different angle to approach the problem with.

The issue was resolved by using two triggers. The first trigger is exactly as above: #trig {@ListVar} and it basically just parses the %line to a variable. The second trigger is my main one, which then compares that the %line in that trigger matches the %line in the previous trigger. This effectively tests for large lists within any line. The only pre-requisite is to have the settings sorted by None and make sure that the first trigger is executed before the second one.

Of course the bad thing is that now i have an extra trigger that is always on and continually writes to a temporary variable. But at the moment it seems a small price to pay for increasing the efficiency in the second trigger.

Thanks for info on %match, you've saved me hours of trying to get it to work with List Vars.
_________________
That which does not kill us, makes us stronger.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net