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
JRSteensen
Beginner


Joined: 27 Jul 2004
Posts: 25

PostPosted: Wed Mar 01, 2017 8:37 pm   

Functions for accessing/manipulating nested variables?
 
Does anyone have any simple functions to manipulate data in nested record variables?

Also, is there a way to nest records in a record variable?

I'd love to do something like this: (pardon the nested dict example in Python. It's what I'm most comfortable with.)

Code:
>>> d = {}
>>> d['dict1'] = {}
>>> d['dict1']['innerkey'] = 'value'
>>> d
{'dict1': {'innerkey': 'value'}}


Basically wanting to create a db of sorts, without using db - trying to make this package as portable as possible.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Mar 02, 2017 12:02 am   
 
Sure you can, and like most things in zScript you can do it many ways.
Code:
$temp="key=valueA|key2=valueB|key3=valueC"
#ADDKEY $temp {key4} {valueD}
#ADDKEY SomeVar {key} {$temp}
#SHOW {key is %db(%db(@SomeVar, "key"), "key") key2 is %db(@SomeVar.key, "key2") key3 is @SomeVar.key.key3}
#ADDKEY SomeVar.key {key} {valueE}
SomeVar.key.key3="valueF"
#LOOPDB @SomeVar.key {
 #SHOW {key: %key is %val}
}
#UNVAR SomeVar
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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