Using an OR statement in MSM Mumps

This is a discussion on Using an OR statement in MSM Mumps within the mumps forums in Programming Languages category; 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...

Go Back   Application Development Forum > Programming Languages > mumps

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 06-27-2008, 06:22 PM
David Hubball
Guest
 
Default Using an OR statement in MSM Mumps

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
Reply With Quote
  #2  
Old 06-28-2008, 03:38 PM
EdM
Guest
 
Default Re: Using an OR statement in MSM Mumps

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
Reply With Quote
  #3  
Old 06-29-2008, 04:43 PM
David Hubball
Guest
 
Default Re: Using an OR statement in MSM Mumps

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
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:04 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.