Changeset 552 for trunk


Ignore:
Timestamp:
Dec 7, 2006, 3:15:58 PM (18 years ago)
Author:
dkearney
Message:

adjusted the formatting to use %g which chops off random zeros at the end of values so integers still look like integers and floats can live happily in "less than 6 digit percision"-land. also added in code to format newval which is the real value being stored in the component. formatting of newval only happens if the newval does not have units attached to it. this fix introduces a place of confusion where the user enters "." into an integer input, the error message states the user needs to enter a floating point number. then the user enters a floating point number and the error message states the user needs to enter an integer. might consider moving the integer check up, in front of the min/max value check

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/gauge.tcl

    r551 r552  
    234234                    $itk_option(-minvalue) -to $nvUnits]
    235235            } else {
    236                 # fix for the case when the user tries to
    237                 # compare values like minv=-500 nv=-0600
    238                 set nv [format "%f" $nv]
    239                 set minv [format "%f" $minv]
    240             }
     236                set newval [format "%g" $newval]
     237            }
     238           
     239            # fix for the case when the user tries to
     240            # compare values like minv=-500 nv=-0600
     241            set nv [format "%g" $nv]
     242            set minv [format "%g" $minv]
     243
    241244            if {$nv < $minv} {
    242245                error "minimum value allowed here is $convMinVal"
     
    252255                    $itk_option(-maxvalue) -to $nvUnits]
    253256            } else {
    254                 # fix for the case when the user tries to
    255                 # compare values like maxv=500 nv=0600
    256                 set nv [format "%f" $nv]
    257                 set minv [format "%f" $minv]
    258             }
     257                set newval [format "%g" $newval]
     258            }
     259
     260            # fix for the case when the user tries to
     261            # compare values like maxv=500 nv=0600
     262            set nv [format "%g" $nv]
     263            set maxv [format "%g" $maxv]
     264
    259265            if {$nv > $maxv} {
    260266                error "maximum value allowed here is $convMaxVal"
Note: See TracChangeset for help on using the changeset viewer.