Archive: Runtime 'binding' of function....


Runtime 'binding' of function....
Say I have three functions

Function myOne
StrCpy $R1 "1"
Function End


Function myTwo
StrCpy $R1 "2"
Function End


Function myThree
StrCpy $R1 "3"
Function End

And I want to read a string from a file, and call the function named from the string: i.e.

Some TextFile:
<COMMENT>abadsjglkg</COMMENT>
<ACTION>myTwo</ACTION>
:End File


Var /Global myFilehandle
Var /Global myFunctionName

FileOpen $myFileHandle "myFileName.txt"
## parse the action line here, so that "myTwo" ends up in
## $myFunctionName
## Then:
call $myFunctionName

; I want to resolve the string
; and call what the string resolves to....
; essentially I want it to become a function pointer....

; What mechanism do we have to do runtime
; interpretation of a string...


Use GetFunctionAddress.

Stu


Um.... no...still needs compile-time literal to be present.
No..... GetFunctionAddress requires a literal.... i.e. This works

Function myFunctionName
Quit
FunctionEnd

GetFunctionAddress $R1 "myFunctionName"
GetFunctionAddress $R1 myFunctionName
Call $R1

This doesn't:

StrCpy $R2 "myFunctionName"
GetFunctionAddress $R1 $R2
Call $R1


You can't. Function names are not saved in the installer itself.