Reference Function Name Via Variable?

Thierry th.douez at gmail.com
Fri Jan 16 02:18:39 EST 2009


Hi all,

# Other ways to manage Ref functions...

on mouseup
     put "hello" into arg1
     put "world" into arg2
     put "shout" into NameOfFunc
     answer value( format( "%s( %s, %s)", NameOfFunc, arg1, arg2 ) )
end mouseup

# Or substitute value & format with a dispatcher function

     answer dispatcher( NameOfFunc, arg1, arg2 )

  function dispatcher NoF, a1, a2
     return value( format( "%s( %s, %s)", NoF, a1, a2 ) )
  end dispatcher


# And a more generic dispatcher.....

     answer dispatcher2( NameOfFunc, arg1, arg2 )


  function dispatcher2 NoF
     put  NoF & "("  into tmp
     repeat with p=2 to the paramcount
        put quote & param( p)  & quote & ","  after tmp
     end repeat
     put ")" into last char of tmp
     return value( tmp )
  end dispatcher2


HTH,
Regards,
Thierry





More information about the Use-livecode mailing list