Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CallByName?
#1
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]
Reply
#2
CALL procname ([parameter list])

http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgCall
Reply
#3
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]
Reply
#4
yeah, like red_Marvin said.

a hash table with function pointers would be the way to go.
Reply
#5
http://www.freebasic.net/forum/viewtopic.php?t=4401 ;p enjoy.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)