--- capa/capa51/GUITools/common.tcl 1999/10/26 16:47:36 1.2 +++ capa/capa51/GUITools/common.tcl 1999/12/13 21:38:44 1.3 @@ -1135,7 +1135,7 @@ proc getOneStudent { window path idVar n ########################################################### ########################################################### ########################################################### -proc getString { window message } { +proc getString { window message {type "any"}} { global gPrompt set setWin [toplevel $window.getstring] @@ -1146,7 +1146,8 @@ proc getString { window message } { set gPrompt(val) "" - entry $valFrame.val -textvariable gPrompt(val) + entry $valFrame.val -textvariable gPrompt(val) -validate key \ + -validatecommand "limitEntry %W -1 $type %P" pack $valFrame.val message $msgFrame.msg -text $message -aspect 3000 @@ -1688,11 +1689,12 @@ proc winprintText { num } { ########################################################### proc limitEntry { window max type {newvalue ""}} { after idle "$window config -validate key" - if {[string length $newvalue] > $max } { return 0 } + if {($max != -1) && ([string length $newvalue] > $max)} { return 0 } switch $type { any {} number { if {(![regexp ^\[0-9\]+$ $newvalue])&&($newvalue!="")} { return 0 } } - letter {if {(![regexp ^\[A-Za-z\]+$ $newvalue])&& ($newvalue!="")} { return 0 }} + letter { if {(![regexp ^\[A-Za-z\]+$ $newvalue])&& ($newvalue!="")} { return 0 }} + nospace {if {(![regexp "^\[^ \]+$" $newvalue])&& ($newvalue!="")} { return 0 }} } return 1 }