Syntax for calling label when using extended routine reference

I get NOROUTINE when I try to call a label in a routine in another namespace:

 

d someLabel^|”OTHERNAMESPACE”|someRoutine(inputVar,.resultByReference)

 

Two questions:

1.  What is wrong with my syntax for calling a label in the other routine, versus just the root of the .int/mac?

2.  Can I pass a parameter by reference when using extended routine reference?

 

  • 0
  • 0
  • 289
  • 0
  • 3

Answers

Renee,

it should work. The syntax is OK.

Are you sure "OTHERNAMESPACE" exists and someRoutine in this namespace too?

Passing a variable by reference is OK too.

Regards
Alex

If that routine uses curly brace style, such label should be marked as public. More details here 

Maybe your code at someLabel^someRoutine in OTHERNAMESPACE calls another routine that exists only in OTHERNAMESPACE. In that case, the <NOROUTINE> error will occur when the call is made. That's because when you d someLabel^|”OTHERNAMESPACE”|someRoutine(inputVar,.resultByReference) you are fetching the routine someRoutine from the database of the OTHERNAMESPACE namespace, but you are executing that code in your current namespace.

This is not the same as swapping to OTHERNAMESPACE, running the code, and then swapping back. For example, if someRoutine accesses globals it will do that from whichever namespace is current.

 

To see an example of this, try the following:

SAMPLES>w $zv
Cache for Windows (x86-64) 2016.2 (Build 636U) Wed Apr 13 2016 20:58:35 EDT
SAMPLES>d main^lookup
 
Lookup: 1-jan-2016...finding birthday...no matches
Lookup:
SAMPLES>zn "user"
 
USER>d main^|"SAMPLES"|lookup
 
Lookup: 1-jan-2016
<NOROUTINE>main+27^lookup *datent
USER 4d1>
 
USER 4d1>q
 
USER>

The code in main^lookup in the SAMPLES namespace calls $$validDOB^datent. When this is attempted from the USER namespace we get a <NOROUTINE> error. Notice that the extended information in the error tells us that the routine it can't find is datent.