[Gambas-user] Run a function from a string?
Bruce Steers
bsteers4 at gmail.com
Sat Aug 28 13:20:13 CEST 2021
Is it ,, could it possibly be possible to run a function from a String?
It would open up all sorts of possibilities.
What i mean is for example maybe i want to make a timer to trigger a
function so i want to supply the function name but not run the function at
that time.
Eg.
Public Sub DeferCommand_Click()
sFunctionName="RunNow"
sFunctionArgs="a message"
tFunctionTimer.Start()
End
Public Sub FunctionTimer_Timer()
Last.Stop
'' This bit is where we hit a wall because i don't think anything like it
is possible, but would be sooo useful if it was.
FMain.Functions[sFunctionName].Call(sFunctionArgs)
End
Public Sub RunNow(sMessage As String)
Print "Running Now\n" & sMessage
End
-------------
I should imaging the 3 dots ... could be utilized to transmit any number of
arguments
I of course have no real clue where to even begin to implement anything
like this.
That would be our Benoits bag of amazing insights :)
(<-- stands back and waits for the "nope, not ever!" :'( ;) )
Any kind of way to implement something like that would be incredibly useful.
I hope I have been clear in my wish here.
kinda like bash 'eval' can turn a string into a function and run it.
Well wishes
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210828/9dc4df56/attachment.htm>
More information about the User
mailing list