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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Tue Apr 20, 2010 11:15 am   

%i and %repeatnum inside of nested loops
 
I believe it's fairly simple but can't remember, or easily find in the help files, how %repeatnum and %i work, inside of nested loops.
The help for predefined variables tells me %i and repeatnum are the same, but testing tells me there are some differences.

#FORALL "a|b" {#FORALL "c|d" {#LOOP 2 {#SAY This is loop %repeatnum of %i}}}

Outputs:
This is loop 1 of a
This is loop 2 of a
This is loop 1 of a
This is loop 2 of a
This is loop 1 of b
This is loop 2 of b
This is loop 1 of b
This is loop 2 of b

Whether I use a #LOOP, #FORALL, #<number> or #REPEAT type of loop, %i seems to always return the index of the outermost loop, while %repeatnum returns the index of the innermost loop. If I have three or more loops, as in the example above, how do I manipulate them all? In this case, how do I get at the index of the #FORALL "c|d" loop?
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Tue Apr 20, 2010 11:46 am   
 
i believe it starts at %i, then %j, %k etc etc

#LOOP 1,5 {#loop 1,2 {#show %i - %j}}

1 - 1
1 - 2
2 - 1
2 - 2
3 - 1
3 - 2
4 - 1
4 - 2
5 - 1
5 - 2
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Tue Apr 20, 2010 12:02 pm   
 
I thought it was simple. Wink Thanks, Private.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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