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
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Tue Aug 21, 2007 3:13 am   

Minor bug: %item and numbers larger then the number of items in the list
 
#loop 4 {#show %i : %item("one|two",%i)}

Can we have this fixed back to the way it was in zMud (i.e. automatically did the %mod math for you) pretty please? (As always, sorry if this has already been brought up, searching for "item" "string list" is less then useful.)
Reply with quote
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Tue Aug 21, 2007 4:53 am   
 
I just tried that on zMUD:
Code:
1 : one
2 : two
3 :
4 :
and CMUD:
Code:
1 : one
2 : two
3 :
4 :

I get the impression that on zMUD it goes one,two,one,two for you?

If it does, I'd consider that a bug, not a feature.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Aug 21, 2007 5:11 am   
 
The only place I've ever heard of the wraparound counter is in the #CASE command...
_________________
EDIT: I didn't like my old signature
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Tue Aug 21, 2007 1:43 pm   
 
Code:
#func loopL %item(%1,%if( %mod( %2, %numitems( %1))=0, %numitems( %1), %mod( %2, %numitems( %1))))
#loop 9 {#show %i : @loopL("one|two|three",%i)}



In fact, Fang would you help file this somewhere? I've wanted this function in the past myself...
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram

Last edited by Arminas on Tue Aug 21, 2007 4:00 pm; edited 1 time in total
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Tue Aug 21, 2007 3:02 pm   
 
Drat, you're right, I was completely getting confused with #CASE.

Although come to think of it, it would still be useful, like Arminas says the math involved is kind of spammy (not difficult, just annoying).
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Tue Aug 21, 2007 5:12 pm   
 
This won't be changed, sorry. There are many cases where it's very important to return a null value when accessing elements outside the range of the array. And the MOD can be done even easier using the \ operator:
Code:
#loop 4 {#show %i : %item("one|two",((%i-1) \ 2)+1)}
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Tue Aug 21, 2007 5:34 pm   
 
That's great Zugg.

I wasn't really asking for a change in the function. I was just Hoping that the example I gave would be added to the %item help.

Your example would be much better. I have just bumped my head on that problem a few times and having forgotten I would look at the help thinking, "Why isn't this mentioned?".
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
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