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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Derar
Novice


Joined: 09 Sep 2006
Posts: 44

PostPosted: Wed Jul 28, 2010 9:13 pm   

[3.22] BUG: #ADDKEY Multi-Key Syntax Discards a Pair
 
#ADDKEY is behaving strangely when using the multi-key syntax to add multiple keys at the same time where some values are non-literal (variable, local variable, function, etc.).

Code:

#ADDKEY TestVar {On=5|test1=%concat("Not ", "Visible")|test2=%concat("Vis", "ible")}
#SHOW @TestVar

Does not work properly, outputting:
Code:

On=5|test2=Visible

The test1 pair was never added.

However,
Code:

#ADDKEY TestVar2 {test1=%concat("Not ", "Visible")|On=5|test2=%concat("Vis", "ible")}
#SHOW @TestVar2

Works just fine, outputting:
Code:

test1=Not Visible|On=5|test2=Visible


Additionally,
Code:

test1 = "hola"
#ADDKEY TestVar3 {Off="On"|%concat(@test1, "!")=Test|On=5|test2=%concat("Vis", "ible")}
#SHOW @TestVar3

Also works, outputting:
Code:

Off=On|hola!=Test|On=5|test2=Visible



What looks to be happening is, if the first pair's value is literal, then the first subsequent pair containing a non-literal value is discarded. All other pairs, whether containing literal or non-literal values, are added as expected, regardless of their position (so, if the first 3 pairs are literals, still only the first non-literal pair is discarded; it doesn't match quantity).

Non-literal keys do not appear to have any problems.

I've had this occur in a few different instances: with %concat, %db, @var, $var. All have the same issue.
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Jul 29, 2010 4:59 pm   
 
I'm afraid you are pushing the {key=value|key=value...} syntax beyond it's limit. This syntax for #ADDKEY is only for backwards compatibility and really shouldn't be used to the extent that you are pushing it. You really should stick with the normal #ADDKEY syntax and do this:
Code:
#ADDKEY TestVar On 5
#ADDKEY TestVar test1 %concat("Not ", "Visible")
#ADDKEY TestVar test2 %concat("Vis", "ible")
#SHOW @TestVar

or use %concat to construct the string list without relying upon implicit concat features, like this:
Code:
#ADDKEY TestVar %list(%concat("On=5|test1=","Not ", "Visible","|test2=","Vis", "ible"))
#SHOW @TestVar
Reply with quote
Derar
Novice


Joined: 09 Sep 2006
Posts: 44

PostPosted: Thu Jul 29, 2010 6:16 pm   
 
If it's only present for backwards compatability, then its importance is obviously at your discretion.

I should point out, however, that it did work as expected in 3.17, which I run as a more or less stable version to actually play, and does not after the json & other list changes up to 3.22, which I've started putting on to test compatability with existing scripts and get up to speed.

Since the syntax is able to handle all the parameters, and only breaks depending on a certain order they're supplied in, I don't know that "being pushed beyond its limit" is what's happening, and I'd be concerned about other similar parameter chewing going on, if there might be any.

Multiple %concats was just an easy way to exemplify it; in practical use (for me anyway) it presents more often in %db or just @var occurrences. As a workaround, pre-%concat on everything is viable, but so is making sure the first pair is non-literal (which I wound up doing).

Thanks for the response!
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Jul 29, 2010 7:13 pm   
 
You could use local variables first, then use #ADDKEY TestVar $Local and see if that works.

Just a thought, anyway, or at least a workaround.

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