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
yelayon
Novice


Joined: 15 Mar 2005
Posts: 42

PostPosted: Wed Jun 17, 2009 8:41 am   

[3.08] Array's values/variables not saves
 
Scenario:
1. Define new variable as %array
2. Set new values
3. Quit cMud, run cMud
4. Check variable values

Code:
#VARIABLE tmparr %array(0,1,2,3)
#CALL %arrset(tmparr,1,"one")
#CALL %arrset(tmparr,2,"two")
#SHOWARR tmparr
#SAVE

Shows:
Code:
Array tmparr = 0:0, 1:"one", 2:"two", 3:3

Now quit cMud and run it again, connect to session. And run command:
Code:
#SHOWARR tmparr

Shows:
Code:
tmparr not an array

In package editor I see defined variable tmparr with initial values (0,1,2,3).
_________________
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Jun 17, 2009 3:17 pm   
 
This is true and is by design. Arrays created with %array are internal COM arrays for use with calling other applications that require specific COM array data types. COM variables are not saved across sessions. zMUD didn't save these either.

You should be using a string list if you want an array to be saved across sessions.
Reply with quote
yelayon
Novice


Joined: 15 Mar 2005
Posts: 42

PostPosted: Wed Jun 17, 2009 4:27 pm   
 
Too bad :(
I use a lot of stringlist, but some stuff was easier to use in arrays.
Good to know that way of arrays are [not] stored has changed.

Suggestion: pls add this information to help section "Changes for zMUD users" b/s I haven't noticed anywhere that arrays are not stored
_________________
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

Last edited by yelayon on Wed Jun 17, 2009 5:32 pm; edited 1 time in total
Reply with quote
yelayon
Novice


Joined: 15 Mar 2005
Posts: 42

PostPosted: Wed Jun 17, 2009 5:31 pm   
 
BTW - string-list is not indexed from 0, but 1 - this makes sometimes big difference.

EOT
_________________
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jun 17, 2009 7:11 pm   
 
It's not a change for zMud users. Arrays were not saved in zMud either.
Reply with quote
yelayon
Novice


Joined: 15 Mar 2005
Posts: 42

PostPosted: Wed Jun 17, 2009 11:14 pm   
 
Rahab wrote:
It's not a change for zMud users. Arrays were not saved in zMud either.
You're wrong - arrays saves in zMud
_________________
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Jun 18, 2009 6:02 pm   
 
Quote:
You're wrong - arrays saves in zMud

Only for certain simple arrays. This feature was very buggy in zMUD depending upon the array contents. zMUD basically tried to convert the array in a string value to save/restore. Various special characters in the elements could break it. Also, COM arrays using %array often refer to other COM components, which are not saved. So you could easily end up with a partial array being restored. It was decided that it was better not to save %array at all rather than having it be buggy and unreliable and to encourage the use of string lists. String lists were slow in zMUD but are fast and optimized in CMUD.

And yes, they are indexed from 1, which is easier for novice users to understand.
Reply with quote
anomarus
Newbie


Joined: 30 Sep 2009
Posts: 3

PostPosted: Fri Oct 16, 2009 8:04 am   
 
arrays save in cmud as variables, #var a %array(1,2) etc
its jus that #SHOWARR doesnt work properly to display them, nether does #var a

if you click on variables button and go look at variable that way it shows all the stored values in the array's index.
Reply with quote
Zugg
MASTER


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

PostPosted: Sat Oct 17, 2009 5:00 pm   
 
Not sure what you mean by #SHOWARR not working. Works fine for me here:
Code:
#var a %array(1,2)
#showarr a

outputs:

Array a = 0:1, 1:2

just like it should. However, I *do* see the problem you are talking about with the settings editor and how it doesn't show the array property when you click the Variables button. I've added that to the bug list.
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Oct 19, 2009 10:24 pm   
 
Actually, I tracked this down.

CMUD *does* save the COM-based arrays created with %array. However, the very first time a session with a saved array is loaded, the

#SHOWARR tmparr

does not work as you mentioned. Doing *anything* that causes the string value of this variable to be shown, even a simple #VAR command will then cause it to work. The reason was that CMUD wasn't creating the COM-based array when the session was loaded until the actual stored *string* value of the variable was accessed.

I have modified the #SHOWARR command (and any other command that tries to directly access the COM array) so that the stored string value of the variable is converted into the array the first time as needed. Fixed for 3.11.
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