SclCountItems
Overview
The SclCountItems command operates on any object that represents a container (or set) of child objects and returns a count of the number of items in the set.
Synopsis
$ContainerObjectHandle SclCountItems
Description
Return a count of the number of child items in the set represented by the container object handle. SclCountItems is very useful for establishing the upper limit of a for loop where SclGetItem will be used to get items from a specified position in the set of child objects.
Arguments
- ContainerObjectHandle
ContainerObjectHandle must be the handle to a set of child objects so that a count of the number of child objects can be determined. The table below shows the different types of container (parent) objects and the type of objects for which the count is returned.
| Parent object type | Type of items (child objects) counted |
|---|---|
| Set of SWAs (sclSwas) | The number of SWAs that exist in the set of SWAs |
| Set of Graphics Layers (sclGraphicsLayers) | The number of SWAs that exist in the set of Graphics layers |
| set of viewports (sclViewports) | The number of viewports that exist in the set of viewports |
| String | Number of segments in the string |
| Segment | Number of points in the segment |
| Triobject | Number of trisolations in the Triobject |
| Trisolation | Number of triangles in the trisolation |
| Set of Databases (sclDatabases) | The number of databases that exist in the set of databases. At this time this number will always be one. This may change in a future release. |
| Database | Number of tables in the database |
| Table | Number of fields in the table |
| Query | Number of columns being retrieved by the query. |
| Insert | Number of columns being modified by the insert operation. |
| InsertUpdate | Number of columns being modified by the insert/update operation. |
| Update | Number of columns being modified by the update operation. |
| Row handle | Number of values retrieved by the row. |
Returns
A count of the number of child objects in the parent set.
Examples
#
# This example shows how a count of the number of SWAs in the set of
# Graphics layers can be obtained and also how a SWA at a specified
# position in the set of Graphics layers be obtained and assigned to a
# variable
#
set count [sclGraphicsLayers SclCountItems]
puts "There are $count Swas in the set of Graphics Layers"
for {set i 0} {$i < $count} {incr i} {
sclGraphicsLayers SclGetItem SwaHandle $i
puts "The Graphics Layer at position $i is [$SwaHandle SclGetId]"
}
|
#
# This example shows how a count of the number of SWAs in the set of SWAs
# can be obtained and also how a SWA at a specified position in the set of
# SWAs can be obtained and assigned to a variable
#
set count [sclSwas SclCountItems]
puts "There are $count Swas in the set of SWAs"
for {set i 0} {$i < $count} {incr i} {
sclSwas SclGetItem SwaHandle $i
puts "The Swa at position $i is [$SwaHandle SclGetId]"
}
|
#
# This example shows how a count of the number of viewports in the set of
# viewports can be obtained and also how a viewport at a specified position
# in the set of viewports can be obtained and assigned to a variable
#
set count [sclViewports SclCountItems]
puts "There are $count viewports in the set of Viewports"
for {set i 0} {$i < $count} {incr i} {
sclViewports SclGetItem ViewportHandle $i
puts "The viewport at position $i is [$ViewportHandle SclGetId]"
}
|
#
# This example shows how a count of the number of strings in the SWA
# can be obtained and also how a string at a specified position in the
# SWA can be obtained and assigned to a variable
#
SclGetActiveViewport ViewportHandle
$ViewportHandle SclGetActiveLayer SwaHandle
$SwaHandle SclGetStrings StringsHandle
set count [$StringsHandle SclCountItems]
puts "There are $count strings in the Swa"
for {set i 0} {$i < $count} {incr i} {
$StringsHandle SclGetItem StringHandle $i
puts "The string at position $i is [$StringHandle SclGetId]"
}
|