Globals and their indices are one of the most important things and it really matters how you define their structure - think about how you are going to use them first!
In your case, I'd recommend one or mix of the following:
(1) redesign your global (or local) array to look like this: ^REF(1,"123456","ABC")
Then you can mix $Order function on 3rd level and direct access via ^REF(1,123456,<something>).
It is much faster, but everything depends on your needs and considerations.
(2) if you really want to "filter" array (global or local) at some level of subscript keys, you can use $Order function in conjunction with '[' operator, as follows:
S X="" F S X=$O(^REF(1,X)) Q:X="" W:(X["123456 A") X,!
Tom
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am hoping someone can help me, being a newbie to gt.m I am struggling with a pattern match
I have a global as followings
^REF(1,"123456 ABC")=4
^REF(1,"223456 SZZ")=76
^REF(1,"223456 VZZ")=45
^REF(1,"223456 FZZ")=33
^REF(1,"123456 AB")=2
^REF(1,"123456 ABZ")=1
I know, I can use ZWRITE to return the global for example
ZWRITE ^REF(1,"123456 ABZ")
and it returns
^REF(1,"123456 ABZ")=1
how would I return all ^REF globals containing 123456 (in the 2nd sub) i.e.
ZWRITE ^REF(1,"123456*") <* being a pattern to say and anything following 12345>, so it would return
^REF(1,"123456 ABC")=4
^REF(1,"123456 ZZZ")=3
^REF(1,"123456 AB")=2
^REF(1,"123456 ABZ")=1
Regard Richard.
Hello,
Globals and their indices are one of the most important things and it really matters how you define their structure - think about how you are going to use them first!
In your case, I'd recommend one or mix of the following:
(1) redesign your global (or local) array to look like this: ^REF(1,"123456","ABC")
Then you can mix $Order function on 3rd level and direct access via ^REF(1,123456,<something>).
It is much faster, but everything depends on your needs and considerations.
(2) if you really want to "filter" array (global or local) at some level of subscript keys, you can use $Order function in conjunction with '[' operator, as follows:
Tom