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: 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! :)
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Sat Jul 14, 2007 10:37 pm   
 
Verified.
Reply with quote
Zugg
MASTER


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

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


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: 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! :)
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: 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.
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Jul 16, 2007 5:13 pm   
 
Confirmed and added to bug list.
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