|
Thinjon100 Apprentice
Joined: 12 Jul 2004 Posts: 190 Location: Canada
|
Posted: Sat Jul 14, 2007 3:59 pm
[1.34] Local variables and #DELKEY |
While #ADDKEY works admirably on local variables, #DELKEY does not function properly, and has a rather undesirable side-effect. It will, instead of deleting the key from the local variable, leave the variable intact, and create a new variable containing part of the variable's contents, with a name equal to the variable's contents.
For example, the following test script:
Code: |
$mydbvar = ""
#ADDKEY {$mydbvar} {"Test1"} {"Hi"}
#ADDKEY {$mydbvar} {"Test2"} {"Hi"}
#ADDKEY {$mydbvar} {"Test3"} {"Hi"}
#ECHO $mydbvar
#DELKEY {$mydbvar} {"Test2"}
#ECHO $mydbvar
|
The echoes return:
Test1 Hi Test2 Hi Test3 Hi
Test1 Hi Test2 Hi Test3 Hi
And, looking in my editor, I now have the lovely variable:
Name: Test1HiTest2HiTest3Hi
Contents:
[null] = Hi
Test3 = Hi
I THINK this is a bug :) There IS a workaround, however... it seems %delkey works fine, so the following works:
Code: |
$mydbvar = %delkey($mydbvar,"Test2")
|
|
|
_________________ If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :) |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Sat Jul 14, 2007 10:37 pm |
Verified.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Sun Jul 15, 2007 6:42 pm |
Try removing the {} around the local variable name. Also, you don't need the extra {} around the " strings. Remember that {} is just like "" except that it allows variable expansion, so you essentially have redundant quotes. The correct syntax should be:
Code: |
$mydbvar = ""
#ADDKEY $mydbvar "Test1" "Hi"
#ADDKEY $mydbvar "Test2" "Hi"
#ADDKEY $mydbvar "Test3" "Hi"
#ECHO $mydbvar
#DELKEY $mydbvar "Test2"
#ECHO $mydbvar |
Let me know if that still fails (I don't have CMUD in front of me at the moment). In any case, the simpler the syntax, the better. |
|
|
|
Thinjon100 Apprentice
Joined: 12 Jul 2004 Posts: 190 Location: Canada
|
Posted: Sun Jul 15, 2007 11:27 pm |
My initial code had no {} around the variable name... thinking that that was perhaps the problem, I added it in my test alias. It fails either way.
The #ADDKEYs work fine, either way... just the #DELKEY that doesn't work.
Tried it with your above syntax, same failure. |
|
_________________ If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :) |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Sun Jul 15, 2007 11:32 pm |
I thought of the same thing, Zugg. I, too, tested it with and without the braces, and both failed the same way.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Jul 16, 2007 5:13 pm |
Confirmed and added to bug list.
|
|
|
|
|
|