If I have understood the objective properly:
columns start @ 1
#!/usr/bin/tclsh
set config(atags) {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
set config(alen) [ llength $config(atags) ]
#debug:
puts stderr "config(atags) $config(atags)"
puts stderr "config(alen) $config(alen)"
proc num2col num {
incr num -1
return [ num2col_helper $num ]
}
proc num2col_helper num {
upvar ::config c
set blk [expr { $num / $c(alen) } ]
set rem [expr { $num % $c(alen) } ]
if {$blk} {
append ret [ num2col $blk ]
}
append ret [ lindex $c(atags) $rem ]
return $ret
}
# test upto 3 letters:
set num 1
while {$num < 800} {
puts [format "num: % 8d col: % 10s" $num [ num2col $num ] ]
incr num
}
# end
uwe