Hello again,
Is it possible to use indirect pointers in swordfish basic ie.
Dim ptrToSub as longWord
ptrToSub = @Myfunction()
If readytorun = 1 Then Goto ptrToSub
Indirect pointers
Moderators: David Barker, Jerry Messina
Hello,
I do not think it's possible with SF to call functions using pointers to functions.
As Tim stated, you can fiddle using Events. They acts somewhat as pointers to procedures.
I think that simply branching to a sub is not correct because when you make an explicit call to a sub, Swordfish generates all needed code to create and manage its stack frame. Switching to a procedure via its addres could make the program instable, especially if it involves interrupts (with context saving/restoring). Do not forgot also that SF use a recycling mechanism for local parameters of functions/subs, so calling a function from a pointer to it does not makes things easy to the compiler to know which functions are active simultaniously.
Regards
Octal
I do not think it's possible with SF to call functions using pointers to functions.
As Tim stated, you can fiddle using Events. They acts somewhat as pointers to procedures.
I think that simply branching to a sub is not correct because when you make an explicit call to a sub, Swordfish generates all needed code to create and manage its stack frame. Switching to a procedure via its addres could make the program instable, especially if it involves interrupts (with context saving/restoring). Do not forgot also that SF use a recycling mechanism for local parameters of functions/subs, so calling a function from a pointer to it does not makes things easy to the compiler to know which functions are active simultaniously.
Regards
Octal