number

Typefunction
DictionaryLCS
LibraryLiveCode Script
Syntax
the number of [{card|cd|background|bkgnd|bg}] {<objectType> | parts | controls}
the number of {<objectType> | parts | controls} [{in | of} <groupRef>]
the number of {backgrounds | groups} [ [{in | of} <cardRef>] {in | of} <stackRef>]
the number of [marked] cards [{in | of} <stackRef>]
the number of {char[acters] | items | words | lines} {in | of} <textString>
the number of elements {in | of} <arrayExpr>
Synonymsnum
Summary

Returns the number of objects of a certain kind, or the number of chunks in a string.

Introduced1.0
OSmac, windows, linux, ios, android
Platformsdesktop, server, mobile
Parameters
NameTypeDescription
objectTypebuttons (or btns):
fields (or flds):
images:
graphics (or grcs):
players:
scrollbars:
EPSs:
audioClips:
videoClips:
groups:
backgrounds:
cards:
groupRef

A reference to any group in the current stack.

cardRef

A reference to any card in the current stack.

stackRef

Any stack reference.

textString

Any string or expression that evaluates to a string.

arrayExpr

Any array or expression that evaluates to an array.

Example
repeat for the number of words in inputString
if the number of card buttons > 0 then doTheButtons
Values
NameTypeDescription
return

The number function returns a non-negative integer.

RelatedProperty: backgroundBehavior, layer
Control Structure: function
Keyword: string, control, integer
Object: stack
Glossary: property, current card, return, group, nest, chunk, read-only, expression, non-negative, object
Command: global, group
Function: length
Description

Use the number function to find out how many of a thing there are.

If you use the form the number of card controls, the number function returns the number of controls on the current card that are not members of a group. The form the number of background controls returns the number of grouped controls that are in a group whose backgroundBehavior property is set to true.

The expression

the number of chars in &lt;textString&gt;

is equivalent to:

the length of &lt;textString&gt;

The expression

the number of backgrounds of &lt;stackRef&gt;

returns the number of groups in the stack.

The expression

the number of groups of &lt;stackRef&gt;

returns the number of groups on the current card of the stack. Groups that are nested inside another group are not counted.

Note: The number is implemented as a read-only global property, but can be more conveniently thought of as a function.

Tagstext processing