Re: How to limit decimals with entry validate

From: shamil (shamild_at_hotmail.com)
Date: 02/28/05


Date: 28 Feb 2005 12:01:20 -0800


I looked through the re_syntax manual page and was playing around
trying to figure out how to also limit the number of digits to the left
of the decimal. I wanted to limit them to a maximum of 3 and thought
[regexp {^[0-9]{0,3}*\.?[0-9]{0,2}$} %P] would work. Unfortunately the
{0,3} is causing problems. Any ideas?

Donald Arseneau wrote:
> shamild@hotmail.com (Shamil D.) writes:
>
> > entry .e -validate key -vcmd {regexp {^[0-9]*\.?[0-9]{0,2}$} %P}
>
> Yes indeed.
>
> If you allow signage, beware that [+-] is illegal regexp (incomplete
> range) so you need [-+]:
>
> entry .e -validate key -vcmd {regexp {^[-+]?[0-9]*\.?[0-9]{0,2}$} %P}
>
>
> I usually specify an -invalidcommand, which can be as simple as bell:
>
> entry .e -validate key -vcmd {regexp {^[-+]?[0-9]*\.?[0-9]{0,2}$} %P}
\
> -invalidcommand bell
>
> but I like to do a little flash:
>
> entry .e -validate key -vcmd {regexp {^[-+]?[0-9]*\.?[0-9]{0,2}$} %P}
\
> -invalidcommand {invalid_entry_alert .e}
>
> # Alert the user of a bad entry by ringing the bell and flashing a
bright background
> # color. The optional "time" argument tells how many milliseconds
to flash.
>
> proc invalid_entry_alert { win {time 70}} {
> catch {
> set bg [$win cget -bg]
> if { ![string equal $bg $::PREF::brightcol] } {
> bell
> if { [string length $bg] } {
> $win configure -bg $::PREF::brightcol
> after $time [list $win configure -bg $bg]
> }
> }
> }
> }
>
> # Preferences; code them as you ummm prefer.
> namespace eval PREF {
> variable brightcol yellow
> }
>
> Donald Arseneau asnd@triumf.ca



Relevant Pages

  • Re: Embedding a Macromedia Flash inside a Word document
    ... I've went through the process and the object is embedded into the document, but the movie is not playing :-(. ... The 'technique' used to run the flash within Word is sort of an edgy ... On the Control Toolbox select the 'More Tools' choice ...
    (microsoft.public.word.newusers)
  • RE: Powerpoint slides containing Flash loading static, not animating?
    ... Sounds like the Playing property may be going to False. ... rewind but may want code to rewind and set playing to True. ... We insert a module for each slide with a Flash movie...just change the third ... I assume you are embedding the Flash files. ...
    (microsoft.public.powerpoint)
  • Re: Flash Player 9 Beta for Linux Is Available
    ... > to a web sitre with flash files on it is weird: Firefox gets horirbly slow, ... Once Flash starts playing, though, flash itself seems ... i t's just the Firefox browser that seems to be very slow. ...
    (Fedora)
  • Re: Need feedback
    ... downloaded and on some setups it might even start playing before it finishes downloading, but its still not a stream. ... If it was a stream, it would play as soon as you clicked on it, and it wouldn't be saved. ... Here's a 167 meg movie that's an hour long, and it will play as soon as you click on it, no matter what system you have, without all that microsoft streaming crap or real networks crap. ... You have to have flash but 99% of people have flash, and flash is free, and it gets installed in your browser without ANY ads. ...
    (alt.gathering.rainbow)
  • Re: Flash Player 9 Beta for Linux Is Available
    ... > to a web sitre with flash files on it is weird: Firefox gets horirbly slow, ... Once Flash starts playing, though, flash itself seems ... i t's just the Firefox browser that seems to be very slow. ...
    (Fedora)