 |
Larkin Wizard

Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Tue Feb 07, 2006 3:41 pm
Simple data record question/request |
Is there an easier way to get items from a data record by position other than to use %expanddb and convert it to a string list? Basically, I don't know (nor care) what the keys are ahead of time, and I just want to display the first 5-10 keys in a status window. If I use a string list, I can use %item to grab the elements. I'd prefer to have something simple to do a similar thing with a data record because it's going to be updated in real time and could be fast changing. Too complex a function would really slow down my display, even though the data records themselves are very fast otherwise. Thanks in advance for any ideas anyone might have on this.
|
|
|
 |
TonDiening GURU

Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Tue Feb 07, 2006 4:57 pm |
Keep the first key of the db record as a list of keys.
#ADDITEM MyRecord.keys Test
#ADDKEY MyRecord Test Value1
etc
Then just show %db(@MyRecord,%item(@MyRecord.keys,1))
untested but I always use an index like that. Also useful to check to see if a record has a key to update, delete or do something. |
|
|
 |
Larkin Wizard

Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Tue Feb 07, 2006 5:59 pm |
Brilliant answer! I shouldn't have to worry about the index becoming one of the keys that get displayed, either, because I control which ones are added... I like it. Thanks!
|
|
|
 |
|
|