You are here: Surpac Concepts > Macros > SCL > Range Commands > SclRangeGetCount
GEOVIA Surpac

SclRangeGetCount

Overview

Get a count of the number of items in an Scl range object. This is necessary so that a for loop can be executed for each member of the Scl range object.

Synopsis

SclRangeGetCount $RangeHandle

Description

SclRangeGetCount returns the count of the number of discrete values in an Scl range object that has previously been created by using the SclRangeExpand command.

This function returns a single integer value that is the number of items in the range referred to by the range handle.

Arguments

  • RangeHandle
  • Passed by value. The handle to the Scl range object that has been previously created by the SclRangeExpand command.

Returns

The SclRangeGetCount command returns $SCL_ERROR to indicate all values are in the range otherwise it returns the number of values in the range.

Examples

#
# in this example the variable count will acquire a value of 10
#
set status [SclRangeExpand handle "1,10,1"]
if {$handle == SCL_UNDEFINED_HANDLE} {
    puts "Undefined range handle"
} else {
    # Loop through the range
    set count [ SclRangeGetCount $handle ]
    for { set i 0 } { $i < $count } { incr i } {
        set status [ SclRangeGet $handle $i value ]
        if {$status == $SCL_OK} {
            # Do some processing with $value
        } else {
            puts "Error getting range value"
            break
        }
    }
    # destroy the range object by destroying the handle variable
    SclDestroy handle
}

See Also

SclRangeExpand
SclRangeGet
SclRangeIncludes