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?
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:
For more info see https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY...
I understand, but the text "public" below, don't should solve the problem of visibility?
This is only for external access to this label, without it, you would not be able to call this from terminal or from another routine or class.
Curly braces makes it private by stack.
Xecute and indirection (@) are outside of the scope of a procedure.
Change the label to:
Where [...] is the public-list, those variables are available outside the scope of a procedure.
If you leave out the procedure brackets, all variable are 'globally' availabe.