Question
· Oct 1

Execute a routine with argument by name - Without using Xecute!

Hello everyone, 
so lets say i have the following:

Hello
Q
say(arg)
    w arg
 Q


and i am trying to execute it by its name such as:


s a = "say^hello"

*execute the name inside a*
 

now I know for a fact that if say were written without any argument then do @a would work!

but I can I pass an argument in this case?
I don't want to use Xecute because I am in need of really high performance code.

 

Product version: IRIS 2019.1
Discussion (2)1
Log in or sign up to continue

I assume, you have a routine 'hello' like this

hello ; this is my hello-test
	 quit
	 
say(arg)
     write arg,!
     quit
     
add(x,y) Public
{
  quit x + y
}

and some variable, set as follows

set rou="hello"
set say="say", add="add"
set a1=5,a2=10, arg="Hello World"
set sayall="say^hello(arg)"
set addall="$$add^hello(a1,a2)"

then you can do things like

do @sayall            ---> Hello World   // command indirection
do @say^@(rou)(arg)   ---> Hello World   // name-indirection
do @say^hello(arg)    ---> Hello World   // name-indirection
do say^@(rou)(arg)    ---> Hello World   // name-indirection
do say^hello(arg)     ---> Hello World

write @addall               ---> 15      // command indirection
write $$@add^@(rou)(a1,a2)  ---> 15      // name-indirection
write $$@add^hello(a1,a2)   ---> 15      // name-indirection
write $$add^@(rou)(a1,a2)   ---> 15      // name-indirection
write $$add^hello(a1,a2)    ---> 15

// Caution, you can't do
write @addall + 3  // with "+ 3", the write command is turned into an
                   // expression, and in turn, the indirection is now
                   // a name-indirection. That gives you a SYNTAX error
                   
// but you can do
write $$@add^@(rou)(a1,a2) + 3 --> 18