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
Latent
Apprentice


Joined: 19 Aug 2002
Posts: 120
Location: USA

PostPosted: Fri Jan 09, 2004 1:43 am   

DB variables and #BU
 
I'm trying to make and upkeep a multistate button out of a db variable... so is there any way to pull out JUST the keys of a variable, and then JUST the values of a variable? Meaning... I have a variable that looks like this... asdf|1234|jkl|567|qwerty|09876 where the letters are keys and the adjacent numbers are their values... I want to be able to pull out asdf|jkl|qwerty and plug that into the state names of a button, and then I want to be able to pull out 1234|567|09876 and put them into the state commands so I end up with something like

#BU 1 {Test} {} {all of the keys in @testList} {all of the values in @testList} {} {} {} {width} {height} {} {} {} {} {} {} {} {} {}

And have it execute this command every time I update @testList by adding in a #BU command to the end of the variable I add entries into @testList with
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Fri Jan 09, 2004 11:29 am   
 
One way would be to not use a database variable, but instead 2 stringlists simulating a database variable.

key={asdf|jkl|qwerty}
val={1234|567|09876}
#AL addkv {#ADDITEM key %1;#ADDITEM val %2}
#AL chkdb {#SHOW %1: %item(@val,%ismember(%1,@key))}

Just an example of how you duplicate a db variable with stringlists. The chkdb alias simulates the %db function. Addkv simulates #ADDKEY. Being two stringlists though, using them with #MENU or whereever else you wish to use them, is simple. Just don't use %sort...

(if you don't like using aliases as functions, you can use #FUNC)
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Fri Jan 09, 2004 12:01 pm   
 
He could use a database variable quite easily, with #loopdb:
#loopdb @testlist {#additem Valuelist {%val};#additem Keylist {%key}}

You might try this:
#BU 1 {Test} {} {%expandlist(@keylist,"|")} {%expandlist(@valuelist,"|")} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}

If it doesn't work, its because it needs to be:
#BU 1 {Test} {} {Key1|Key2|Key3|...} instead of
#BU 1 {Test} {} {@listvarcontainingkeys}
Reply with quote
Latent
Apprentice


Joined: 19 Aug 2002
Posts: 120
Location: USA

PostPosted: Fri Jan 09, 2004 9:16 pm   
 
Ahh, that's a brilliant solution Danlo, thank you, I'll try it out and try to get something to work
Reply with quote
Latent
Apprentice


Joined: 19 Aug 2002
Posts: 120
Location: USA

PostPosted: Fri Jan 09, 2004 9:29 pm   
 
Apparently you can't use functions in the state name or command sections =/ Now I just get a button with the function as a title
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