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


Joined: 12 Aug 2003
Posts: 14

PostPosted: Wed Aug 13, 2003 1:33 pm   

Array Bugs?
 
Every now and then, for seemingly no reason at all, all of my array variables will bug out. Instead of containing the information in the array, they instead only show their value to be
Code:
<array>
and nothing else. I can't retrieve or add values to them when this happens and have to restart them from scratch. Is this a bug in zmud or am I doing something to cause this?
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Thu Aug 14, 2003 2:17 am   
 
Are you trying to directly assign arrays anywhere? If so, that would cause this problem since array objects are special variables which require special commands/functions to manipulate.

For example:

#VARIABLE Array1 %array(1, 2, 3)
#VARIABLE Array2 @Array1
#SHOW Treating Array1 and Array2 as standard variables:
#SHOW @Array1
#SHOW @Array2
#SHOW Treating Array1 and Array2 as arrays:
#SHOWARR Array1
#SHOWARR Array2

You'll see that when we use #SHOW on the variables, they both return an identical result: <Array> But when we use #SHOWARR we find out that one is an array and the other is not (since it was assigned from the expansion of @Array1 which is <Array> like the #SHOW command told us).

If you want to copy from one array to another, you could do something like:

#ALIAS copyarray {#VARIABLE %2 %array();#LOOP 0,%arrhigh(%1) {#NOOP %arrset(%2, %i, %arrget(%1, %i))}}

And then you can do:
copyarray Array1 Array2

Of course, since you haven't posted the code for how you are using your array variables, it's rather hard to say why it's happening.
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