|
Latent Apprentice
Joined: 19 Aug 2002 Posts: 120 Location: USA
|
Posted: 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 |
|
|
|
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: 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) |
|
|
|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: 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} |
|
|
|
Latent Apprentice
Joined: 19 Aug 2002 Posts: 120 Location: USA
|
Posted: 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
|
|
|
|
Latent Apprentice
Joined: 19 Aug 2002 Posts: 120 Location: USA
|
Posted: 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
|
|
|
|
|
|