Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
harley
Apprentice


Joined: 05 Apr 2008
Posts: 121

PostPosted: 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
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
harley
Apprentice


Joined: 05 Apr 2008
Posts: 121

PostPosted: Sun Apr 06, 2008 11:19 am   
 
Tried @AutoPracData.SpellsToPrac Already,
failed Figured that i was stuck..
Thanks for the quick response
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: 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.
Reply with quote
harley
Apprentice


Joined: 05 Apr 2008
Posts: 121

PostPosted: 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
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: 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
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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