SclRangeExpand
Overview
Expand an Scl range specification and assign a unique value to a variable to permit access to the range object that has been created.
Synopsis
SclRangeExpand RangeHandle $RangeExpression
Description
The RangeExpression is used to create a range object that defines a set of values, file ID's, string numbers, etc.
The handle to the range object may be used by SclRangeGetCount, SclRangeGet and SclRangeIncludes to determine the number of values in the range, to get a specific value from the range or to determine if a value is included in the range, respectively.
Creating the range object with SclRangeExpand causes a certain amount (only small) of memory to be reserved for the range object. This memory is automatically freed when the script terminates execution. This memory may be explicitly freed by calling SclDestroy on the range handle variable.
Arguments
- RangeHandle
- RangeExpression
Passed by reference. The unique identifier for the range object is assigned to the variable. This identifier may then be used by SclRangeGetCount, SclRangeGet and SclRangeIncludes.
The RangeHandle is set to $SCL_UNDEFINED_HANDLE on error.
Passed by value. The RangeExpression must be a valid range for successful creation of the range object.
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 object by destroying the handle variable
SclDestroy handle
|