Paramcount caution

Jim Hurley jhurley at
Fri Dec 27 17:41:00 EST 2002

>Jim Hurley wrote:
>>  on mouseUp
>  >    put "3,4" into a
>>     print1 a
>>     print2 a
>>  end mouseUp
>>  on print1 x,y
>>     get the paramcount
>>     if it is  1 then
>>       put item 2 of x into y
>>       put item 1 of  x into x
>>     end if
>>     put x &  return  after field 1
>>     put y & return after field 1
>>  end print1
>>  on print2 x,y
>>     print1 x,y
>  end print2

>  Jan Schenkel wrote:
>  When you call print2 it has only 1 parameter, which it places
>into x. Since it can't find a 'y' parameter, it
>assumes you want to create it and thus passes an empty
>value as the second parameter to print1.

Jan and Dar,

Thanks for clearing up this distinction between "empty" and 
"missing". I'm sure the assumption made in Transcript  (i.e. assume 
that an empty  parameter was intended) is the right one in most 
cases. It is one of the many assumptions that must be made in a 
language as forgiving as Transcript. I will settle any day for these 
occasional points of confusion to the alternative of rigid typing 
rules for variables.

In the future I will take the coward's way out and just duplicate in 
toto those handlers that call synonyms which make use of the 
paramcount. Don't tell anybody.
Jim Hurley

More information about the Use-livecode mailing list