Re: Count of Tab characters
Re: Count of Tab characters
- Subject: Re: Count of Tab characters
- From: Richard 23 <email@hidden>
- Date: Sun, 21 Jan 2001 01:13:27 -0800
>
"count" gives the number of somethings in the object, usually characters or
>
items (in a list). It is a verb, not a property, so the correct syntax would
>
be "count tabchar" and not "count of tabchar" (the latter form is used for
>
things like "first word of document", or another example, "count words of
>
document"). However, you don't want to use "count" directly on tab
>
characters; you need something to locate them first, and then count the
>
pieces the tabs separate.
I knew I'd seen it before and although it seems a little awkward there's
nothing wrong with "count of". In fact the AppleScript Language Guide
v1.3.7
(when do we get a new one?) on p137 has this example:
In the following example, referenceToObject is windows of
application
"Finder", which is a list of windows.
The Finder counts the windows in the list.
count of windows of application "Finder"
"of" can also be used to call a handler defined with positional
parameters.
Here's one of the rare examples where I have used it:
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d2
-- ---------------------------------------------------------
property Line_Comment_Space : "-- " -- string for a line comment plus a
space
property Column_Width : 80 -- suggested line width, not used much though
set theDiv to Line_Comment_Space & (RepeatString of "-" for (Column_Width
- (Line_Comment_Space's length)))
--
---------------------------------------------------------------------------
-- repeats a given string a specified number of times and returns the
result
--
---------------------------------------------------------------------------
on RepeatString of theStr for theNum
set myStr to ""
repeat theNum times
set myStr to myStr & theStr
end repeat
return myStr
end RepeatString
-- ---------------------------------------------------------
No big deal. It's just that "correct" as in "the correct way" (or
whatever)
happens to be one of my hot buttons! 8)
R23