|
JRSteensen Novice
Joined: 27 Jul 2004 Posts: 35
|
Posted: 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. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: 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 |
|
|
|
|
|