TABLE OF CONTENTS
::pwtk::expandSequence
SYNOPSIS
proc ::pwtk::expandSequence {seq {increment 1}} {
PURPOSE
Expands the sequence string "from-to" to explicit range of integer numbers.
Allowed values for sequence strings are "from-to" or "from - to". If $seq does not represents a sequence, it can have a non-integer value.
EXAMPLE
expandSequence 1-5 ... returns 1 2 3 4 5 expandSequence {1 - 5} ... returns 1 2 3 4 5 expandSequence 5-1 2 ... returns 5 3 1 expandSequence 6 ... returns 6 expandSequence 1* ... returns 1* expandSequence dummy ... returns dummy
ARGUMENTS
- seq -- sequence string to expand
- increment -- [optional, default = 1] the increment step
SOURCE
set n12 [split $seq -] if { [llength $n12] == 2 } { set first [string trim [lindex $n12 0]] set last [string trim [lindex $n12 end]] if { ! [string is integer -strict $first] || ! [string is integer -strict $last] } { pwtk::error "wrong range \"$seq\", must be N1-N2, where N1 and N2 are integers" 1 } if { $first > $last } { return [seq $first -$increment $last] } else { return [seq $first $increment $last] } } return $seq }