I have been playing with following usage of CALL DWORD.
Define a general template for e.g. subroutine calls with - say - 1 to 4 arguments:
All subroutines are then programmed using appropriate names.
Then for every sub I want to call, I store the procedure address into a variable, e.g. in an array.
Also arguments could be stored in an array.
Now I can call any of these subs with a call
instead of using e.g.
and supply only those arguments which are appropriate.
My simple tests show that this works. What kind of problems do you see w/this approach? I'll be grateful for any comments.
TIA
Lasse Rantanen
[email protected]
Define a general template for e.g. subroutine calls with - say - 1 to 4 arguments:
Code:
DECLARE SUB CDECL FuncTemplate(BYVAL X1 as ANY _ [,BYVAL X2 as ANY _ ,BYVAL X3 as ANY _ ,BYVAL X4 as ANY])
Code:
SUB MySub1(BYVAL X AS INTEGER) ... END SUB SUB MySub2(BYVAL Y AS LONG, BYVAL Z AS BYTE) ... END SUB
Code:
CodePtr(1) = CODEPTR(MySub1) CodePtr(2) = CODEPTR(MySub2) ...
Code:
' Instead of X = 2 ' do for variables eventually used as arguments for ' a certain subroutine Arg1(1) = 2
Code:
CALL DWORD CodePtr(i) USING FuncTemplate(Arg1(i), Arg2(i), Arg3(i), Arg4(i))
Code:
SELECT CASE i CASE 1 MySub1 X CASE 2 MySub2 Y, Z ... END SELECT
My simple tests show that this works. What kind of problems do you see w/this approach? I'll be grateful for any comments.
TIA
Lasse Rantanen
[email protected]
Comment