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
tyebald
Newbie


Joined: 01 Apr 2010
Posts: 7

PostPosted: Fri Apr 09, 2010 11:56 pm   

[3.14b] #ADDKEY command will overwrite variables
 
First off, I understand that I'm still testing with an older beta version, but I can't upgrade yet. I do review the release notes for the other beta releases, to see if the issue I'm raising looks like it may already have been addressed.

Second, I couldn't fit the whole description into the title. I wanted to put, "#ADDKEY command will overwrite variables of type 'Database Record', if the variable is in a Module flagged 'Local' instead of 'Global'. I ran out of space.

Duplication
Fairly straightforward to duplicate, so I don't have a full test jig done up for it. Pick any variable of type Database Record that already contains multiple Key/Value pairs in it. Move the variable to a Local Module. Execute "#ADDKEY db_variable_name key value". Whether the key already exists in the database record or not, the variable will now only contain the key/value from the command (or multiple keys/values, if executed within the single #ADDKEY invocation).

Move the variable back to a Global Module, and the variable goes back to behaving as expected.

Workaround
The syntax of "db_variable_name.key = value" still appears to work as expected. But with that syntax, it becomes difficult to specify Keys that have spaces in the string. The only solution I've found for that, so far, is to put the string into a local variable, and use "db_variable_name.local_var = value", which appears to work.


I've found one of the cool uses of Local Modules has been to abstract out data from scripts and "protect" it from inadvertent editing except through functions/aliases/etc. dedicated to the task. So it would be great to see this addressed, even though scripts can theoretically be rewritten to avoid the problem.

Tyebald
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Apr 10, 2010 1:04 am   
 
This is an issue of package inclusion, and it doesn't matter whether a module is local (your issue) or external (my issue) and perhaps also global (haven't tested yet). It comes down to which window has the focus, as I think that's how scope is derived.

In an amusing twist, I've had this happen when the DB module had focus so I'm not sure if system windows (DB module, mapper, package editor, text editor, etc) are exempt from this.
_________________
EDIT: I didn't like my old signature
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Apr 12, 2010 4:50 pm   
 
You will need to create a full procedure using the latest version. Here is what I just tried and it worked fine:

1) #ADDKEY db_var key1 value1
#ADDKEY db_var key2 value2

2) Open package editor. Click on db_var variable and confirm that is looks ok.

3) New/Module. Make sure it is set as Local, enter "testmod" as name and click Save Changes

4) Drag the db_var from the untitled window to the "testmod" module.

5) On the command line, type:
#ADDKEY db_var key3 value3

6) Back in the package editor, click on the db_var variable and confirm that it now has three keys.

The above procedure worked fine. Are we confused on the terminology here? Did you create a whole new package for the local module, or just create a local module within your main session package?

Also, what is preventing you from upgrading to 3.16b? I'm not aware of any big problems in the latest version that would prevent an upgrade.
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