Paramcount caution

Dar Scott dsc at swcp.com
Fri Dec 27 14:27:01 EST 2002


On Friday, December 27, 2002, at 11:19 AM, Jan Schenkel wrote:

> If you change the script of  handler print2 to:
>
> on print2 x,y
>   if the paramCount is 1 then
>     print1 x
>   else
>     print1 x,y
>   end if
> end print2
>
> Then you'll get the result you expected.

I should have waited for Jan's response before I started writing.  Well, 
a little redundancy might help.  (Jan and I have been struggling with a 
similar problem, so it would seem likely we would both jump on this.)

You can generalize the above to handle a paramCount() of 0 through, say, 
7 with a switch statement.  This has the advantage in that it does not 
need the "do" and will pass arrays (I think).  The more general case of 
"any" number of parameters might require building a "do" string with the 
right number of param() calls, but will not pass arrays (I think).

Anybody got a good general solution to Jim Hurley's challenge?

Dar Scott




More information about the use-livecode mailing list