Note: This is a work in progress and many formatting issues have been fixed. Read more about the project on the home page.
number
the number of [card] {buttons|parts}
the number of bkgnd {buttons|parts}
the number of card fields
the number of [bkgnd] fields
the number of marked cards the number of cards [in bkgnd] ¬
[of this stack]
the number of bkgnds [of this stack]
the number of windows
the number of menus
the number of menuItems of menu
the number of chunks in expression
Values returned: A non-negative integer equal to one of the following:
- total number of buttons or fields on the current card or background
- total number of parts (buttons and fields combined) on the current card or background
- total number of marked cards, cards in a specific background, cards in an entire stack, or backgrounds in a stack
- number of all the windows (including built-in palettes and external windows) in HyperCard
- number of menus in the menu bar or the number of menu items in a specified menu
- total number of characters, words, items, or lines in the value of any HyperTalk expression (treated as text)
Examples
-- Count the menu items in a menu:
the number of menuItems of menu 2
the number of menuItems of second menu
the number of menuItems of menu "File"
-- Count the number of objects:
the number of card fields
the number of background buttons
the number of cards
the number of cards of this background
the number of backgrounds
the number of parts
the number of background parts
-- Count the number of chunks in text (including containers):
the number of chars in card field 2
the number of lines in the stacksInUse
-- Do something based on the number of cards:
repeat with i = 1 to the number of cards of this background
statements
end repeat
repeat with i = 1 to the number of marked cards
statements
end repeat
Demo Script
on numberOfChunks
get bkgnd field "Demo Script"
answer "There are" && the number of lines in it && ¬
"lines and" && the number of words in it && "words and" && ¬
the number of characters in it && "characters in this handler."
end numberOfChunks
Related Topics
Placeholders
bkgnd
A HyperTalk expression that identifies a background by name, number, or id, using one of the following forms:
bkgnd id posInteger
bkgnd text -- name
bkgnd posInteger -- number
ordinal bkgnd
position bkgnd
For example:
bkgnd id 3894
bkgnd "Index"
bkgnd 1
prev bkgnd
previous bkgnd
next bkgnd
this bkgnd
first bkgnd
last bkgnd
middle bkgnd
any bkgnd
From within a background script, the term me
refers to that background.
When a background receives a the message [the] target
, that message is referring to the background.
See also: card
menu
An expression that evaluates to one of the following:
menu text
menu posInteger
ordinal menu
For example:
menu "File"
menu 2
second menu
chunks
One of the following:
characters
chars
words
items
lines
expression
HyperTalk Definition
Any HyperTalk expression. All expressions evaluate to text, a number, or a constant.
For example:
true
sin(90)
"this is" && it
(3+2) = 5
the heapspace div 1024
Note: Formally, HyperCard distinguishes between factors (simple values) and expressions. The difference between factors and expressions matters only if you like to drop parentheses. Most functions take factors as their parameters, which is why length of 3 + 5
returns 6
and length of (3 + 5)
returns 1
. In short, always use parentheses to group things the way you want them to evaluate, and you won’t have to worry about the difference between factors and expressions.
AppleScript Definition
Any series of words that has a value.
HyperTalk Reference