diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2018-05-10 20:35:06 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2018-05-10 20:35:06 -0400 |
commit | 3474a52179d3fd1f1cd6d75fdc781b441840aec3 (patch) | |
tree | f7bdd5ada24bf24b8b08c765bd70245114b20fd1 /GradeBook_lib.tcl | |
parent | 7d09a9b16d54b5d5ff6b79f1d2c106e5a6245b25 (diff) | |
download | GradeBook-3474a52179d3fd1f1cd6d75fdc781b441840aec3.tar.gz GradeBook-3474a52179d3fd1f1cd6d75fdc781b441840aec3.zip |
safety net for plotting char index
Diffstat (limited to 'GradeBook_lib.tcl')
-rwxr-xr-x | GradeBook_lib.tcl | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 21b590e..000bdfe 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -2307,6 +2307,11 @@ proc data2txtPlot { data } { foreach x $data { # funky 1.1 are needed to convert it to floats set cnt [expr { round((1.0*$x-$minVal)/(1.1*$diffVal)*(1.1*($barsNum-1.0))) }] + + # safety check on counter value + set cnt [expr {min($cnt, ($barsNum-1))}] + set cnt [expr {max($cnt, 0)}] + set bar [lrange $chars $cnt $cnt] lappend strPlot $bar } |