Reference Function Name Via Variable?

Rob Cozens rcozens at pon.net
Thu Jan 15 19:14:10 EST 2009


Hi Scott,

>Is there any way to construct a function using a name
>stored in a variable without resorting to "do"?  For example:
>
>on mouseUp
>    put "hello" into pData1
>    put "world" into pData2
>    put "shout" into test
>    do "answer" && test & "(pData1,pData2)"
>end mouseUp
>
>function shout pData1,pData2
>    return pData1 && pData2
>end shout
>
>Can the last line of the mouseUp handler be written without "do"?  I'm not
>against using "do", just wondering if there's another option.

on mouseUp
    put "hello" into pData1
    put "world" into pData2
    put "shout" into test -- in a real world example the value of 
"test" would be derived elsewhere
    switch test
       case "shout"
          answer shout(pData1,pData2)
          break
       case "whisper"
          answer "psst"&&pData2
          break
       case "bye"
          answer "Hasta la vista,"&&pData2
          break
       case "anotherFunction"
          answer anotherFunction(pData1,pData2)
    end switch
end mouseUp


Rob Cozens CCW
Serendipity Software Company

"And I, which was two fooles, do so grow three;
  Who are a little wise, the best fooles bee."

  from "The Triple Foole" by John Donne (1572-1631) 




More information about the use-livecode mailing list