Kevin,
What do you want to happen when the error is detected?

Your third example would give a syntax error. I would expect this to be a 
programming
error. In my work, it seems that the standard error response of logging the 
error and
halting (or dropping back to the MUMPS shell) is generally the best way to 
handle these
kinds of errors, unless you can catch them much earlier (composition rather 
than use of
the construct).

If pRef is expected to be a literal global reference then a function to check 
its syntax
would be pretty easy to write.



Kevin wrote:
>I have a question about how to protect against indirection errors.
>
>Imagine this function
>
>MyFunct(pRef)
>   new result
>   set result=$get(@pRef)
>   quit result
>
>
>Here are some possible inputs and results:
>
>     pRef
>     Input                Output
>     ------                 ----------
>#1 ^VA(200,1,0)   IRM,[EMAIL PROTECTED]
>#2 ^VA(200,1)      ""
>#3 ^VA(200,,0)    <----- causes error.
>
>In entry #2:  if the data does not exist, then $get() protects against
>a crash and returns a "" value.
>But in entry #3, the indirection variable is invalid and causes an error.
>
>Is there anyway for a function to protect itself against invalid
>indirection errors, short of setting up an error trap?  I can't think
>of any reasonable way to try to validate input values other than
>perhaps a simple test to ensure pRef'="" (which would only catch one
>possible error).
>
>Thanks
>Kevin

---------------------------------------
Jim Self
Systems Architect, Lead Developer
VMTH Computer Services, UC Davis
(http://www.vmth.ucdavis.edu/us/jaself)


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Hardhats-members mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hardhats-members

Reply via email to