Paramcount caution

Jim Hurley jhurley at infostations.com
Fri Dec 27 13:11:01 EST 2002


Here is something I found confusing.

In its simplest form my problem is this:

I define a button with the script:

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


I would have assumed that the two handlers "print1" and its synonym 
"print2" would be identical since "print1" just calls "print2", but 
they are not.  When "print2" calls "print1", it appears to pass two 
parameters even though y is empty.

The result of "mouseUp" in field 1 is:

3
4
3,4

I would have thought it would be

3
4
3
4

The origin or this problem is that I was trying to students a choice 
of synonym for an operation, and they could use either.  But that 
will be a problem in handlers which count parameters in this way. I 
get the feeling there is a subtle difference between "empty" and 
"missing"???????

Jim Hurley



More information about the use-livecode mailing list