Posts: 684
Threads: 64
Joined: May 2004
Is there such a function in FB? In VB6, you can call a function by passing a string to CallByName. Is this possible in FB?
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Posts: 476
Threads: 35
Joined: May 2006
Posts: 1,080
Threads: 87
Joined: Feb 2002
TheAdventMaster: In that example the sub/function name isn't in a string...
Torahteen: AFAIK that is not possible, but you could set up an
array with sub names and their pointers
Pseudocode:
Code:
type subListEntry
name as string
p as functionpointer
end type
dim shared subList(0 to ?) as subListEntry
sub init_sub_list
subList(0).name="sub0"
subList(0).p=@sub0
subList(1).name="sub1"
subList(1).p=@sub1
...
end sub
sub call_a_sub(sname as string,parameters)
for n=0 to ?
if subList.name=sname then
@subList.p parameters
exit sub
end if
next
end sub
/post]
yeah, like red_Marvin said.
a hash table with function pointers would be the way to go.