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
Novice


Joined: 27 Jul 2004
Posts: 35

PostPosted: 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~_*"))
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4671
Location: Pensacola, FL, USA

PostPosted: Thu Oct 06, 2022 1:57 pm   
 
#LOCAL $count
#FORALL %dbkeys(@dbvar) {#IF (%match(%i, "{O|T}HS_")) {$count=($count+1)}}
_________________
Discord: Shalimarwildcat
Reply with quote
JRSteensen
Novice


Joined: 27 Jul 2004
Posts: 35

PostPosted: 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
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4671
Location: Pensacola, FL, USA

PostPosted: 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
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