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


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Mon Apr 23, 2007 3:10 am   

String lists in database var
 
Having a slight problem with string lists in database variables.

It seems that when you add a string list to a database var (either in the editor, or with #ADDKEY), if there are parenthesis in the string list, the editor adds quotes.

It doesn't add the quotes around the specific string list item that has the parenthesis (as is the behavior in zMud), but around the entire db var item.

i.e.

zMud: #ADDKEY myvar mykey {a|b|c (d)}
Look in editor: mykey: a|b|"c (d)"
@myvar.mykey.3 returns: c (d)

cMud: #ADDKEY myvar mykey {a|b|c (d)}
Look in editor: mykey: "a|b|c (d)"
@myvar.mykey.3 returns: c (d)"
incidentally... @Myvar.mykey.1 returns "a

This has the unfortunate side-effect of adding unfortunate quotes in my scripts.

My current workaround is stripping quotes as I use the values, but that'll only work until I decide to add something that /has/ quotes.
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Mon Apr 23, 2007 3:12 am   
 
OK, after looking again.... this is /not/ just when adding string lists...

#ADDKEY myvar mykey {blah blah (blah) blah}
@myvar.mykey returns "blah blah (blah) blah"

in this instance, it's adding quotes again... and again I have to strip them before I can use the value.
_________________
If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :)
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Apr 23, 2007 3:17 am   
 
Confirmed. Changing the third item to %quote(c (d)) also doesn't work.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Mon Apr 23, 2007 1:26 pm   
 
Ah, I have been dealing with this by setting the variable to auto type before doing the string list and back to database type after dealing with them. After work I will pull out the code I'm using for this and post it here.

I've been playing with Larkin's Acropolis and to make it work I had to find the work around! So I'll post the add and delete stuff from there.

I was in goof off mode when I fixed this so I didn't even think to post about it. Embarassed
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Apr 23, 2007 4:58 pm   
 
Added the bug list.
Reply with quote
Gregorius
Beginner


Joined: 12 Nov 2006
Posts: 16

PostPosted: Mon Apr 23, 2007 5:41 pm   
 
This also relates to stringlist variables, though not inside a database. I don't know if I am doing something wrong or if it is a bug:
So I am updating my database information with a following line:
Another alias defines @kya stringlist with lots of information.
#dbput (%find(@monname)) {Align=@kya.24}

Field Align becomes null.
Also trying to go around it by definining:

Alignment=@kya.24
gives value to @alignment nothing. However '#echo @kya.24' gives the correct value

EDIT: found the way, using %item(@kya,24) gives correct value

EDIT2: but... #dbput (%find@monname)) {Align=%item(@kya,24)} still gives null...


Last edited by Gregorius on Tue Apr 24, 2007 3:06 pm; edited 3 times in total
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Tue Apr 24, 2007 3:20 am   
 
Sorry this is a bit later than I had intended to post this but here you go.

These are from the Acropolis i_add and i_del aliases in combat/internals class.

i_add
Code:
#exec {#call %vartype(%1,0)}
#if (%null(%3))
 {
  #forall {%2}
   {
    #exec {"#additem "%1".keys {"%i"}"}
   }
  #exec {#call %vartype(%1,5)}
  #exec {"#addkey %1 {%2} 1"}
 }
 {
  #forall {%2}
   {
    #exec {"#additem "%1".keys {"%i"}"}
   }
  #exec {#call %vartype(%1,5)}
  #exec {"#addkey %1 {%2} {%-3}"}
 }


i_del
Code:
#exec {"#call %vartype("%1",5)"}
#forall {%-2}
 {
  #exec {#call %vartype(%1,5)}
  #delkey %1 {%i}
  #exec {"#delitem "%1".keys {"%i"}"}
  #exec {"#call %vartype("%1",5)"}
 }
#if (%1 == afflictions) {i_del flags failsafe}
#exec {"#call %vartype("%1",5)"}

Note that these deal with adding and removing both keys and items from string lists within a database variable. I decided to post these intact as they give you generic aliases for dealing with databases with string lists. That and Larkin hadn't updated these scripts on his web site and this is a major part of fixing Acropolis for Cmud

Please note that Larkin made these to be able to handle adding and removing more than one key or item at a time. So if you do not intend to do this you can do away with the #forall commands.

As for them making sense? I'm sure they could be cleaned up. They work. So hopefully they will help someone until the bug gets worked out.
_________________
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