About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Mon Oct 01, 2007 5:46 pm   

[2.04] %arrset in the #LOOP does not work
 
The task: create an array MobLevel[0...45] and fill it with default values.

Code:

#VAR MobLevel %array(0,1,2,3,4,5);
#NOOP %arrset(MobLevel,45,777);
#NOOP %arrset(MobLevel,44,776);
#NOOP %arrset(MobLevel,43,775);
#LOOP 0,5 {#NOOP %arrset(MobLevel,%i,10)}
#LOOP 6,45 {#NOOP %arrset(MobLevel,%i,100)}

#LOOP 0,45 {#ECHO "Loop counter i =" %i "Array element[i] =" %arrget(MobLevel,%i)}

#VAR MobLevel;


Output:
Code:

Loop counter i = 0 Array element[i] = 0
Loop counter i = 1 Array element[i] = 1
Loop counter i = 2 Array element[i] = 2
Loop counter i = 3 Array element[i] = 3
Loop counter i = 4 Array element[i] = 4
Loop counter i = 5 Array element[i] = 5
Loop counter i = 6 Array element[i] =
Loop counter i = 7 Array element[i] =
Loop counter i = 8 Array element[i] =
Loop counter i = 9 Array element[i] =
Loop counter i = 10 Array element[i] =
........
Loop counter i = 40 Array element[i] =
Loop counter i = 41 Array element[i] =
Loop counter i = 42 Array element[i] =
Loop counter i = 43 Array element[i] = 775
Loop counter i = 44 Array element[i] = 776
Loop counter i = 45 Array element[i] = 777

Variable: + MobLevel            (Array)       <Array>|0|1|2|3|4|5
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Mon Oct 01, 2007 6:44 pm   
 
Try using #CALL instead of #NOOP - I think that might be a change compared with zMUD, that perhaps isn't as well documented as it should be. Or maybe there is no change.
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Mon Oct 01, 2007 6:55 pm   
 
Seb
Yeah, it helps, thanks!
But #VAR MobLevel; still show me

Variable: + MobLevel (Array) <Array>|0|1|2|3|4|5

Is that ok?


And I ask for CMUD documentation update for arrays.
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Mon Oct 01, 2007 7:18 pm   
 
Arde wrote:
Is that ok?

I don't know, but use:
#SHOWARR VarName
to display arrays properly.
Reply with quote
Zugg
MASTER


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

PostPosted: Tue Oct 02, 2007 12:27 am   
 
Arrays created using %arrset are internal Windows COM objects. You cannot display them just using #VAR. You *must* use #SHOWARR (or your own loop).

And yes, you should be using #CALL instead of #NOOP.

Arrays are not well documented because you should normally use string lists instead. There is a lot more support in CMUD/zMUD for String Lists. The %arrset and COM arrays are just there for people who need COM-compatible arrays for calling other applications.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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