counting empty items

Dar Scott dsc at swcp.com
Tue May 25 13:03:50 EDT 2004


On Monday, May 24, 2004, at 11:09 AM, rand valentine wrote:

>  If I do this:
>
> set the itemDelimiter to tab
> put the number of items of tab & tab & tab & tab
>
>  1 is returned.
>
> why not 4? I don't get it.

This example may help:

on mouseUp
   put empty

   put the length of comma & comma & comma & comma after message
   put lf after message
   put the number of items of comma & comma & comma & comma after message
   put lf after message

   put lf after message

   put (the length of comma) & comma & comma & comma after message
   put lf after message
   put (the number of items of comma) & comma & comma & comma after 
message
   put lf after message

   put lf after message

   put the length of (comma & comma & comma & comma) after message
   put lf after message
   put the number of items of (comma & comma & comma & comma) after 
message
   put lf after message

end mouseUp

== into message box ==>

1,,,
1,,,

1,,,
1,,,

4
4


Now imagine what that would look like with tabs as delimiters.

(If you are wondering why 4 and not 5 is put in the message box, just 
ask.)

Just as parentheses make a difference in these arithmetic expressions, 
it does in Transcript expressions:
    1-2+3
    (1-2)+3
    1-(2+3)

Dar Scott



More information about the use-livecode mailing list