|
JerleMin Novice
Joined: 17 Oct 2000 Posts: 38
|
Posted: 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 |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sat Sep 21, 2002 5:10 am |
#LOOP
Classes
#IF
List functions
#WHILE
LightBulb
Senior Member |
|
|
|
Charbal GURU
Joined: 15 Jun 2001 Posts: 654 Location: USA
|
Posted: 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 |
|
|
|
|
|