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
zwanth
Beginner


Joined: 13 Jul 2002
Posts: 16
Location: USA

PostPosted: Wed Jan 14, 2004 1:14 am   

%i and nested LOOP/FORALL
 
If I have two FORALLs and/or LOOPs nested, is there a way I can get the current index for the innermost loop?

For example:
#LOOP 5 {
#FORALL @stringlist {
#SAY %i
...
}
}

The %i in this example gives me the current index from the outer loop(1,2,3,4,5) and not the string list in #FORALL. Is there a way to get the current name from @stringlist, or a better way to script this?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Jan 14, 2004 1:58 am   
 
%j

#LOOP 5 {
#FORALL @stringlist {
#SAY %j
...
}
}
Reply with quote
zwanth
Beginner


Joined: 13 Jul 2002
Posts: 16
Location: USA

PostPosted: Wed Jan 14, 2004 2:31 am   
 
%j is exactly what I needed... This really should be added to the Predefined Variables list in the help file.

Thanks for your assistance.
Reply with quote
patryn
Apprentice


Joined: 26 Sep 2001
Posts: 124

PostPosted: Thu Jan 15, 2004 11:44 pm   
 
Wow, very handy.
I always made use of temporary variables, which no doubt slowed the computing of such algorithms down a lot.

Thanks Lightbulb, you just made made my settings twice as efficient as they used to be Very Happy
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Thu Sep 08, 2005 1:06 am   
 
Just curious LightBulb (or anyone) where did the %j come from?
I mean, how did you know about it? Help file in zmud, also online make no ref to %j.
just wondering if maybe something like this would make my assembly question come together..
http://forums.zuggsoft.com/phpbb/viewtopic.php?t=22007

Prolly not tho..*sigh*
_________________
http://www.Aardwolf.com
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Sep 08, 2005 2:16 am   
 
I know it's in the version notes (or rather, that it appeared there; if Zugg had to rebuild those as well I guess it could be possible it might have been forgotten), and I know that Zugg did announce this on the forums when first released. May not have survived the move to wolfpaw, though.
_________________
EDIT: I didn't like my old signature
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Thu Sep 08, 2005 4:08 am   
 
sadly cant search for %j otherwise i woulda found that :(

Thanks
_________________
http://www.Aardwolf.com
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Thu Sep 08, 2005 3:56 pm   
 
the 1st loop is %i, loops/foralls/etc nested inside that use %j,%k,%l,etc

enter this on the command line:
Code:

#loop 1 {
  #loop 2 {
    #loop 3 {
      #loop 4 { #SHOW I: %i - J: %j - K: %k - L: %l
    }
   }
  }
}


Last Loop Output:
Code:

I: 1 - J: 2 - K: 3 - L: 4
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