Question
· May 19, 2021

Variable <Undefined> using Xecute command

Hello everyone,

 

I have a question, I am trying to use xecute command, but something wrong happen when i was using the command, and i don't know why hahahaha.

I created a file .mac with this code:

label(test) public{
       set routine="variable"
       set call="write routine,!"
       xecute call
       quit
}

But when i run the command, show me this message error:

<UNDEFINED>label+3^tstFJR3 *routine

After that i changed the code to:

label(test)
      set routine="variable"
      set call="write routine,!"
      xecute call
      quit

This solved the problem to me, and writed this content:

variable

Someone can explain to me, why this happend? 

Discussion (4)2
Log in or sign up to continue

First off, it's generally best to avoid xecute. ;)

In the first case, routine is private (it isn't visible in the xecute stack frame). In the second, it's public, so it is visible there.

You could get the best of both worlds with:

ClassMethod Run()
{
   set routine="variable"
   set call="(routine) write routine,!"
   xecute (call, routine)
   quit
}

For more info see https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY...