Page 1 of 1
Calling Procedures by Name
Posted: Thu Aug 21, 2014 12:42 am
by Foz
Is it possible, somehow, to call a procedure within the same executable, but by using the name of the procedure, or a label to locate the address of the procedure or some other way of doing it?
My current solutions is either a massive Select Case statement, or I use DLLs which have stringy return issues...
Re: Calling Procedures by Name
Posted: Thu Aug 21, 2014 12:54 am
by Danilo
You could use maps or runtime procedures.
With maps, you need to initialize them with the function pointers first.
With runtime procedures, init is done automatically.
Code: Select all
Runtime Procedure abc()
Debug "abc() called"
EndProcedure
Runtime Procedure xyz()
Debug "xyz() called"
EndProcedure
Prototype NoArgs()
Define f.NoArgs
;---------------------------------
f = GetRuntimeInteger("xyz()")
If f : f() : EndIf
f = GetRuntimeInteger("abc()")
If f : f() : EndIf
;---------------------------------
NewMap functions.i()
functions("abc")=@abc()
functions("xyz")=@xyz()
f = functions("xyz")
If f : f() : EndIf
f = functions("abc")
If f : f() : EndIf
Re: Calling Procedures by Name
Posted: Thu Aug 21, 2014 5:22 am
by Foz
Well damn, when did that runtime library get added?
It's been sat under my nose all this time...
Thanks Danilo!
Re: Calling Procedures by Name
Posted: Thu Aug 21, 2014 3:53 pm
by Lothar Schirm
Hello Foz,
the runtime library has been added with Version 5.20 LTS.
