· May 2, 2016

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?

Discussion (3)0
Log in or sign up to continue

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:

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 matches
SAMPLES>zn "user"
USER>d main^|"SAMPLES"|lookup
Lookup: 1-jan-2016
<NOROUTINE>main+27^lookup *datent
USER 4d1>
USER 4d1>q

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.