Livecode Wiki
Advertisement

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

the number of {char[acters] | items | words | lines} {in | of} <string>

Examples:

repeat for the number of words in inputString
if the number of card buttons > 0 then doTheButtons

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(command). The form the number of background controls returns the number of grouped controls that are in a group(command) whose backgroundBehavior property is set to true.

The expression

   the number of chars in string 

is equivalent to

   the length of string 


The expression the number of backgrounds of stack returns the number of groups in the stack. The expression the number of groups of stack returns the number of groups on the [[current card]] of the stack. groups that are nested inside another group(command) are not counted.

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

Parameters:

  • objectType: One of buttons (or btns), fields (or flds), images, graphics (or grcs),players, scrollbars, EPSs, audioClips, videoClips, groups, backgrounds,or cards.
  • group: A reference to any group in the current stack.
  • card:
  • stack:Any stack reference.
  • string (string): Any string or expression that evaluates to a string.
  • Returns: The number function returns a non-negative integer.

See also: function (control structure),length (function),control (object),backgroundBehavior (property),layer (property),

Advertisement