From 3474a52179d3fd1f1cd6d75fdc781b441840aec3 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Thu, 10 May 2018 20:35:06 -0400 Subject: safety net for plotting char index --- GradeBook_lib.tcl | 5 +++++ 1 file changed, 5 insertions(+) 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 } -- cgit v1.2.3