 |
harley Apprentice
Joined: 05 Apr 2008 Posts: 121
|
Posted: Sun Apr 06, 2008 10:43 am
%pop in a stringlist from a DB |
I think i'm doing this correctly.. but i dont think it works
If it doesnt work i can go back to just using the other form of stringlist
But i would much prefer to have it from the db
Code: |
#addkey AutoPracData NextSpell {%pop(%db(@AutoPracData,SpellsToPrac))}
#if (@AutoPracData.NextSpell = %null) {
#show Practicing complete
#addkey AutoPracData AutoPrac "Off"} {
~prac @AutoPracData.NextSpell
} |
thats what i have.. It works from a stringlist, thanks for any input |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Apr 06, 2008 10:49 am |
%pop takes a string argument which is the name of the variable, not a stringlist argument to edit (else how would it remove the item from the variable?). I'm not sure how you'd work around this without simply not using a stringlist inside a data record variable. You could try AutoPracData.SpellsToPrac for the argument, but I wouldn't get my hopes up.
|
|
|
 |
harley Apprentice
Joined: 05 Apr 2008 Posts: 121
|
Posted: Sun Apr 06, 2008 11:19 am |
Tried @AutoPracData.SpellsToPrac Already,
failed Figured that i was stuck..
Thanks for the quick response |
|
|
 |
Larkin Wizard

Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Sun Apr 06, 2008 11:21 am |
You don't use the @ with %push and %pop. They take the string name of the variable, not the variable itself which gets expanded to its value by use of the @ prefix.
|
|
|
 |
harley Apprentice
Joined: 05 Apr 2008 Posts: 121
|
Posted: Sun Apr 06, 2008 11:29 am |
I thought you had to with %db, I tried both ways and didnt work either..
edit:: i think i understand what you mean.. you mean Autopracdata.qwerty vs @AutoPracData.qqwerty |
|
|
 |
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Sun Apr 06, 2008 1:35 pm |
Push and Pop were never intended to work within a database variable period!
If you still want to use them you will need to add a couple of steps to make it work.
Code: |
$tvar=@AutoPracData.SpellsToPrac
#addkey AutoPracData NextSpell {%pop($tvar)}
#addkey AutoPracData SpellsToPrac {$tvar}
#if (@AutoPracData.NextSpell = %null) {
#show Practicing complete
#addkey AutoPracData AutoPrac "Off"} {
~prac @AutoPracData.NextSpell
} |
That is the general idea at least. I still haven't written the test case to work out any bugs.
Expect another post in a few minutes. |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
 |
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Sun Apr 06, 2008 1:52 pm |
This is the test case that shows that the above should work.
Hopefully it is self-explanatory.
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<alias name="pptest" copy="yes">
<value>$tvar="cat|dog|mouse|bird"
#show tvar $tvar
#addkey dbvar list {$tvar}
#show dbvar @dbvar.list
#show popping tvar %pop($tvar)
#show tvar after pop $tvar
#addkey dbvar list {$tvar}
#show dbvar after pop @dbvar.list
$tvar=%push("house",$tvar)
#show tvar after push $tvar
#addkey dbvar list {$tvar}
#show dbvar after push @dbvar.list
#addkey dbvar next {%pop($tvar)}
#addkey dbvar list {$tvar}
#show dbvar next @dbvar.next
#show dbvar list after popping for next @dbvar.list</value>
</alias>
</cmud> |
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
 |
|
|