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
JerleMin
Novice


Joined: 17 Oct 2000
Posts: 38

PostPosted: Sat Sep 21, 2002 1:35 am   

Help requested
 
Hi,
I'm trying to write an expbot. What I need to do is to make an interruptible #forall. I have a string list that needs to be done in order, but #forall won't work because I need t obe able to turn it off. Any suggestions?

Jerle Minara,
zMUD 6.34
Win 2k Advanced Server
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Sep 21, 2002 5:10 am   
 
#LOOP
Classes
#IF
List functions
#WHILE

LightBulb
Senior Member
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Sat Sep 21, 2002 5:11 am   
 
Depending on your use (which you didn't tell us), you may not need to interrupt the #FORALL at all. You might instead use an #IF inside the commands to execute that would just do nothing (#NOOP) if the conditions which indicated you wanted to cancel were met.

For example,
#FORALL @stringlist {#IF (@Cancel = 0) {tell %i Hello;#WAIT 1000} {#NOOP}}

Note, this uses #WAIT, usually not a good thing to do (see here). However, delaying a loop is the only supported use of #WAIT so we are fine.

If you do need to interrupt the loop, you have two options. Either use #FORALL and the #ABORT command to interrupt it or make your own version of #FORALL. The latter strategy would entail keeping a variable indicating which item in the list you are on and then use %item to go through everything.

More information would help in selecting the best method for your purpose.



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