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
The Raven
Magician


Joined: 13 Oct 2000
Posts: 463

PostPosted: Mon Nov 13, 2006 11:28 pm   

[1.15] #ADDITEM does not convert a String to a String List
 
Recreate:

#VAR Working {First Item}
#ADDITEM Working {Second Item}

If you view the 'Working' variable in the Package Editor, it is a String List, with a database-record style UI.

#VAR Broken {First Item|Second Item}
#ADDITEM Broken {Third Item}

If you view the 'Broken' variable in the Package Editor, it is a plain expanded String, with the text 'First Item|Second Item|Third Item'.

Expected Result:

The 'Broken' variable should have been converted to a String List when the #ADDITEM command was used on it.

Comments:

There does not appear to be a programmatic way to change the type of a variable after it has been created. This makes it difficult to create string lists that are pre-filled with many items. It would be nice if there was a way to insta-create a variable (with a single command) that had many items in it, rather than having to start with one item and loop through #ADDITEM to add all the rest.

Another alternative would be a way to set the type of a variable explicitly from the code.
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Nov 13, 2006 11:43 pm   
 
You can change a variable type using the %vartype function. Check the help file for it. And you *can* create a string list with all the items in it. Just do this:

#VAR Working {First Item|Second Item|Third Item}

So you don't need to use #ADDITEM if you don't want to.

In general, don't worry about the data type. The auto-type variables should work fine. But yes, I will fix #ADDITEM to mark it as a String List. It should have been set to AutoType and not an expanded String by the #VAR command because of the | character, so that's also a bug.
Reply with quote
The Raven
Magician


Joined: 13 Oct 2000
Posts: 463

PostPosted: Tue Nov 14, 2006 3:23 am   
 
Thanks Zugg. I hadn't read closely enough... I thought the %vartype function only retrieved the type... I didn't realize it could set it.
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