count(list)

Tinderbox Icon


Operator Type:   Function
Operator Scope of Action:   List
Operator Purpose:   Mathematical

count(list)

The function count() counts the number of discrete items in the specified List or Set data type attribute. Prior to v5.6.0, this operator required Set data.

Alternatively, use List/Set.size.

count(attribute)

The attribute argument is evaluated so can use, $attribute(note) or more complex expressions to get data - as long as the result is an attribute of the Set data type.

For example if KeyAttributes for the current note is "Color;Color2;NameFont" then the code

count($KeyAttributes) 

is effectively

count(Color;Color2;NameFont) 

and not surprisingly returns 3. Note that the count is not all unique values for the attribute across the whole TBX - scope is restricted to 'this' note or another nominated note. Specimen usage:

count($KeyAttributes) 

count($KeyAttributes(some other note)) 

count(list)

The following is a trivial example (given we could use $ChildCount instead) but shows how count can be used in a more subtle way:

$MyNum = count(collect(child,$Name)) 

The result of collect is a List, in this case a number of note titles. count will return the number of values in the list (including duplicates). To get a de-duped count, pass the collect data into a set before doing the count:

$MySet = collect(child,$Name); $MyNum =count ($MySet) 


Possible relevant notes (via "Similar Notes" feature):

Up: List-based operators

A Tinderbox Reference File : Actions & Rules : Operators : Action Operator Scope : List-based operators : count(list)

Quicklinks: Attributes | Action Codes | Export Codes | Designators | Date Formats | aTbRef Site Map

[Last updated: 16 May 2012, using v5.11.1]


Search:

Google search aTbRef for:  


Creative Commons Licence

aTbRef by Mark Anderson is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

[See aTbRef CC licence Attribution & Waiver info]

Made with Tinderbox