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
Virus
Wanderer


Joined: 29 Jun 2002
Posts: 69
Location: USA

PostPosted: Thu Feb 13, 2003 5:08 am   

iter()
 
Ok, we all know that muxes and mushs have commands similar to #LOOP called @dolist. Now what I want to know is there a ZMUD function similar to iter()? If there it it would be awesome.

Richard Powell
Mux Alias: Virus
2796 Wizard Staff
64.89.10.1 port 2796
Rich@gigdev.com
Reply with quote
Emit
Magician


Joined: 24 Feb 2001
Posts: 342
Location: USA

PostPosted: Thu Feb 13, 2003 5:41 am   
 
maybe if you could explain a little more, i just play merc derivatives mainly.

--------

moon.icebound.net:9000
Reply with quote
Virus
Wanderer


Joined: 29 Jun 2002
Posts: 69
Location: USA

PostPosted: Thu Feb 13, 2003 6:56 am   
 
Function: iter(list, eval[, delim])

list is a delimter-separated list of strings, which can be object
numbers, attributes, or arbitrary words. eval is a string that is to be
evaluated once for each item in list, replacing the special symbol ## with
the corresponding item from list, and the symbol #@ with the position
within the list being iterated. A space-separated list of the results
of these evaluations is returned to the caller. The effect is very similar
to @dolist, except that the results are made into a list and returned, not
executed.

Examples:
> say iter(This is a test,strlen(##))
You say "4 2 1 4"
> say iter(This is a test,{strlen(##)})
You say "4 2 1 4"
> say iter(lnum(10),mul(mul(##,##),10))
You say "0 10 40 90 160 250 360 490 640 810"
> say iter(lcon(me),[name(##)]..[money(##)])
You say "test..1 t1..1 radio..1 The Wizard's Pointy Hat..1"
> say iter(Was it a cat I saw,[words(##)] #@,s)
You say "1 1 4 2 1 3"
See also: @dolist, list(), parse().


Richard Powell
Mux Alias: Virus
2796 Wizard Staff
64.89.10.1 port 2796
Rich@gigdev.com
Reply with quote
Castaway
GURU


Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Thu Feb 13, 2003 9:29 am   
 
We 'all' dont know anything about Muxes and Mushes, at least, I dont.. So you shouldnt assume we have a clue..

Having said that, no, there is no equivalent command. The nearest you can get is using #FORALL @list {}, which loops through a list and sets %i to each item, which can then be used in the commands in {}.

You could try and create your own, using #FUNCTION and #FORALL.

I'm guessing something like:


#FUNCTION iter
{
#VAR answer "";
#FORALL %1
{
#VAR item %replace(%2, ##, %i);
#ADDITEM answer, %eval(@item);
}
@answer;
}


Untested!

Lady C.
Reply with quote
Virus
Wanderer


Joined: 29 Jun 2002
Posts: 69
Location: USA

PostPosted: Thu Feb 13, 2003 1:53 pm   
 
Ohhh....I was under the impression that you couldnt use COmmands in a function. Now that i know I can that makes it a lot easier. I can just make a function and use #LOOP. Thx

Richard Powell
Mux Alias: Virus
2796 Wizard Staff
64.89.10.1 port 2796
Rich@gigdev.com
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Feb 13, 2003 5:27 pm   
 
I was under that impression too. I can't test right now, and Castaway did mention that the script was untested so, Virus, does it work?

Kjata
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Thu Feb 13, 2003 6:28 pm   
 
It is possible to use commands in a function, but it has to be done in such a way that it returns a value. This generally means using the %exec function as a wrapper for the commands.

 - Charbal
Reply with quote
Castaway
GURU


Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Thu Feb 13, 2003 9:54 pm   
 
Having looked at the help for #function as I wrote that, I couldnt find any indication of how it knows what to return, and assumed (!) that it just returns the last value mentioned. (Which would be my @answer list)..

Terrible help page that.. If it needs a complete internal function (no idea why it should) then you'll have to be clever with %eval/$exec as Charbal said.

Sorry for any confusion :)

Lady C.
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