|
JRSteensen Novice
Joined: 27 Jul 2004 Posts: 35
|
Posted: Sun Oct 02, 2022 1:58 am
Counting keys in record var that match a specific prefix. |
Have a number of keys in a record variable with different prefixes. (OHS_xxx and THS_xxx)
I'm curious how I can countkeys of only the OHS prefixed keys?
Code: |
%numkeys(%match(@StatusDB,"OHS~_*")) |
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4715 Location: Pensacola, FL, USA
|
Posted: Thu Oct 06, 2022 1:57 pm |
#LOCAL $count
#FORALL %dbkeys(@dbvar) {#IF (%match(%i, "{O|T}HS_")) {$count=($count+1)}} |
|
_________________ Discord: Shalimarwildcat |
|
|
|
JRSteensen Novice
Joined: 27 Jul 2004 Posts: 35
|
Posted: Fri Oct 07, 2022 10:10 am |
Awesome! Thanks Shalimar! That is very very useful!
On the same vein, is there a link to examples of using nested record variables? Been having a tough time locating any simple examples to build off of.
I've been having trouble using the syntax: DB.Key1.NestedKey2 = NestedKey2Value |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4715 Location: Pensacola, FL, USA
|
Posted: Fri Oct 07, 2022 1:42 pm |
I prefer using function calls to the dot syntax, especially if you are filling in the keys via script:
%db(%db(@var, Key1), Key2) |
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|