|
AmongTheDecay Beginner
Joined: 25 Apr 2009 Posts: 28
|
Posted: Mon Nov 16, 2009 11:53 am
Database Variable and functions |
Is there a way to get the database variable functions to work with variables that contain special characters?
I have a couple variables stored in my item list that have number values but some of the items are:
* crystal *
>> sword <<
ect
When I try and change or access their values with .* crystal * or with the db functions nothing is returned. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Nov 16, 2009 3:03 pm |
Use the functions instead of the dot notation, e.g. %db(@myvar,"* crystal *")
|
|
|
|
AmongTheDecay Beginner
Joined: 25 Apr 2009 Posts: 28
|
Posted: Mon Nov 16, 2009 6:31 pm |
Neither way works.
|
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Mon Nov 16, 2009 6:42 pm |
AmongTheDecay:
Are you doing it via a trigger? Such as:
#TRIGGER {({@myvar})} {#SAY %db(@myvar, %1)}
?
I've found that special characters don't work like that for some reason, though when you do it directly on the command line, it does.
Charneus |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Nov 16, 2009 7:48 pm |
If %1 doesn't work in the %db() function (I haven't tried it), then try assigning the value to a local variable and using that:
Code: |
#TRIGGER {({@myvar})} {$item = %1;#SAY %db(@myvar, $item)} |
Charneus, have you reported that problem? I don't recall it offhand, but I've been pretty busy for a while. |
|
|
|
AmongTheDecay Beginner
Joined: 25 Apr 2009 Posts: 28
|
Posted: Mon Nov 16, 2009 8:01 pm |
I first noticed it not working in a trigger but I tried via the command line with just #SAY %db(@items, * crystal *) and that didn't work either
|
|
|
|
GeneralStonewall Magician
Joined: 02 Feb 2004 Posts: 364 Location: USA
|
Posted: Mon Nov 16, 2009 8:43 pm |
AmongTheDecay wrote: |
I first noticed it not working in a trigger but I tried via the command line with just #SAY %db(@items, * crystal *) and that didn't work either |
Try using quotes around "* crystal *". Also, make sure there's not a space character your missing somewhere. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Nov 16, 2009 9:07 pm |
Yes, you need the quotation marks. Your string has both special characters and spaces, so without the quotation marks, Cmud doesn't know how to interpret it.
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Nov 16, 2009 9:29 pm |
Quotes will work if you are putting together a literal name. If you are doing this via a variable (%1, $localvar, etc), however, quotes won't work so you should try surrounding it in {}.
In general, CMud does not restrict the characters that can be used in variable names (although I get the feeling it's supposed to). This means that the more "wrong" you make the variable name the more difficulty you will have in accessing it and in fact some of the most extreme things may make the variable totally impossible to refer to. Spaces, special character symbolics that CMud uses, other symbolics, single- and double-quotes, etc. You can even have a variable named %1, which is just totally messed up because CMud actually can't tell the difference between a @var named %1 and the system-defined variable %1 unless you include the @. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
AmongTheDecay Beginner
Joined: 25 Apr 2009 Posts: 28
|
Posted: Mon Nov 16, 2009 9:38 pm |
Ya I've done it with the "s. I was responding via iPod and got lazy. Sorry.
|
|
|
|
|
|