# Generates ranges of numbers in the form of
# macros for Zel.

puts "Welcome to Zel Range!"
puts "Enter the name of the zel file to create:"
gets stdin infile
if {$infile == "" } {puts "Good bye for now!" 
exit 0
}
puts "Please enter the starting number of the range to create (0-127):"
gets stdin startnum
while {$startnum < 0 || $startnum > 127 } {puts "Error! Number out of range! Please try again." }
puts "Please enter the end of the number range to create."
gets stdin endnum
while {$endnum < $startnum || $endnum > 127 } {puts "Error! Number out of range! Please try again." }

puts "Please enter the step value of the range."
gets stdin step
puts "Generating zel file... Please wait."

set zelfile [open $infile a+]
for {set num $startnum } {$num<$endnum } {incr num $step } {
puts $zelfile "set n$num \{$num \} "
}

puts -nonewline $zelfile "pick numrange \["
for {set num $startnum } {$num<$endnum } {incr num $step } {
puts -nonewline $zelfile "n$num "
}
puts $zelfile "\] "
close $zelfile
puts "Done!"
