| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi All I'm new to this group and just looking for a few pointers if anyone would like to help me. Would anyone know a better way of writing an OR command than this, to return a TRUE value if one or both global exists. My attempt is :- w $D(^GLOB("SUB1","SUB2"))!$D(^GLOB2("SUB1","SUB2")) Also if anyone thinks what I have written if fine then please also let me know. Kind Regards David |
|
#2
| |||
| |||
| On Jun 27, 6:22*pm, David Hubball <davidhubb...@talktalk.net> wrote: > w $D(^GLOB("SUB1","SUB2"))!$D(^GLOB2("SUB1","SUB2")) > > Also if anyone thinks what I have written if fine then please also let > me know. In general, this should be OK, especially if there is a pretty good chance that both global variables exist. If you want to reduce the time needed to check for the second global variable if the first one exists, you could encapsulate this as s x=$$check() with: check() i $d(^GLOB("SUB1","SUB2")) q 1 i $d(^GLOB2("SUB1","SUB2")) q 1 q 0 In this sample function, the code would look for the second global variable only if the first one does not exist. If there is a good likelihood that by checking for a specific one first, accessing the second one can be avoided, there might be a benefit in this approach. If references to both global variables happen frequently in the code at hand, information for both variables will be in cache anyway, and the original code (i.e. $D(^GLOB("SUB1","SUB2"))!$D(^GLOB2("SUB1","SUB2")) ) won't be using any unnecessary resources. Now, if the purpose is to fetch a value from either of two locations, I'd write something like: Set value=$Get(^GLOB("SUB1","SUB2")) Set:value="" value=$Get(^GLOB2("SUB1","SUB2")) This code avoids a second disk-access if the first one is successful, and communicates to the (human) reader that the second retrieval only is intended to happen when the first one doesn't return any valid data. Hope this is useful, Ed |
|
#3
| |||
| |||
| Hi Ed Thanks for confirming this for me. I've tried learning mumps before where I work but I am now getting more heavily involved with it. No doubt I'll be posting a few more topics in the next few months to come. I think you are brilliant. Thanks very much. Kind Regards David |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.