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
Aleron
Wanderer


Joined: 01 Aug 2005
Posts: 76

PostPosted: Wed Aug 03, 2005 1:58 pm   

%additem problem
 
I set up the following alias, named test:

#VAR targetQueue %array( "item1", "item2")
#VAR targetQueue %additem( "item3", @targetQueue)
#VAR targetQueue %additem( "item4", @targetQueue)
#VAR targetQueue %additem( "item5", @targetQueue)

The thing is, after I execute this, targetQueue has the following contents: Array, item3, item4, item5. If I just execute the first line, it adds item1 and item2 like exected. However, for some reason unknown to me, the first time I %additem it completely destroyes whatever was in the list prior to that call (not to mention the 'Array' entry). Does that seem normal to anyone? I would assume a function named %additem would simply append what I pass it to the end of a list. Can anyone shed some light on this for me?
Reply with quote
Aleron
Wanderer


Joined: 01 Aug 2005
Posts: 76

PostPosted: Wed Aug 03, 2005 2:49 pm   
 
Right, so after talking with a friend, I changed the first #VAR statement to this:

#VAR targetQueue "item1"

He said that lists and arrays SHOULD be the same thing in zMUD, but they aren't. This fixed the problem. So, now I have to follow up questions.

1) Why do arrays and string lists exist in the present form where they are not equivalent?
2) Why not add a list function for instantiating a new list, similar to %array, but that will work %additem the way that it should work?
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Wed Aug 03, 2005 2:54 pm   
 
Unless i am misunderstanding the %array help file, don't think you are doing it right.
Should be %additem as well.
I just tried it and it added them all.
The %array only put in item5
_________________
http://www.Aardwolf.com
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Wed Aug 03, 2005 3:25 pm   
 
1. If I remember correctly, lists were added as a variant type of variable very early in zMud development. Lists are fast, easy and convenient and the - #ADDITEM, %additem, #DELITEM and %delitem - commands and functions were created to manipulate string lists directly.

The %array function was added much later to facilitate COM functionality. To communicate with other COM objects, a strict type definition was needed so the %array function was added for this reason.


2. A COMMAND for instantiating a new list, which works with %additem the way it should, already exists...
#VAR example_string_list {first_value|second_value|third_value}
Reply with quote
Aleron
Wanderer


Joined: 01 Aug 2005
Posts: 76

PostPosted: Wed Aug 03, 2005 3:39 pm   
 
Ah, I can see the purpose of having %array around now, thanks. Yes, I figured out I can just use %additem to add an item to an already existing variable, and it works nicely. Thanks for the response! :)
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