ProcedureReturn (bis) : return more than only one parameter
Posted: Wed Aug 29, 2007 6:17 pm
There is already a post explaining this option but I read it. If you aren't french, it's harder to understand it...
Actually we can't get only one returned parameter from a procedure:
But usually, the stack keeps the value of the inputs until they are overwritten after the call of the procedure.
A new command (I invent a name for example : many) should allow to get these values.
Example:Syntax 1
Or Syntax 2(syntax like 'CallFunction')
Application (syntax 2 only):
Reading this code, I think Fred could understand, in one kind, the simplicity to add such a function, and, in an other kind, my difficulty to create only one good macro respecting the syntax number one or a better syntax!
I know there's structures to answer such a problem but it could be a very good and simple solution.
Actually we can't get only one returned parameter from a procedure:
Code: Select all
output = Proc(input1, input2)
A new command (I invent a name for example : many) should allow to get these values.
Example:Syntax 1
Code: Select all
Many(p, q, r, s) = Proc(a, b, c, d)
Code: Select all
Many(Proc, a, b, c, d)
Code: Select all
;{
Macro ProcReturn
! Ret
EndMacro
Macro Func1(p, a)
p(a)
! Pop [v_#a#]
EndMacro
Macro Func2(p, a, b)
p(a, b)
! Pop [v_#a#]
! Pop [v_#b#]
EndMacro
Macro Func3(p, a, b, c)
p(a, b, c)
! Pop [v_#a#]
! Pop [v_#b#]
! Pop [v_#c#]
EndMacro
Macro Func4(p, a, b, c, d)
p(a, b, c, d)
! Pop [v_#a#]
! Pop [v_#b#]
! Pop [v_#c#]
! Pop [v_#d#]
EndMacro
Macro Func5(p, a, b, c, d, e)
p(a, b, c, d, e)
! Pop [v_#a#]
! Pop [v_#b#]
! Pop [v_#c#]
! Pop [v_#d#]
! Pop [v_#e#]
EndMacro
;}
; *** MAIN ***
Declare MyProcedure(a, b, c, d, e)
Func5(MyProcedure, a, b, c, d, e)
Debug a
Debug b
Debug c
Debug d
Debug e
Procedure MyProcedure(One, Two, Three, Four, Five)
One = 111
Two = 222
Three = 333
Four = 444
Five = 555
ProcReturn ; << /!\
EndProcedure

I know there's structures to answer such a problem but it could be a very good and simple solution.