> Does anybody have an  example of ADP page to validate if
> one variable is numeric ?

I use the following procedure for that. It's not perfect but it works for
me.  I included my test procedure for any number, integer, and if a number
is 0.

Note that IsNumber and IsInteger consider an empty string to NOT be a
number.  You might want to change that depending on your application.

proc IsNumber { number } {
    set number [ string trim $number ]
    return [ expr [regexp {^[+-]?( |\t)*[0-9]*(\.[0-9]*)?$} $number] && [string length 
$number] ]
}

proc IsInteger { number } {
    set number [ string trim $number ]
    return [expr [regexp {^[+-]?( |\t)*[0-9]*$} $number output] && [ string length 
$number ] ]
}

proc IsZero { num } {
    lassign [ split $num . ] a b
    set a [ string trim [ string trim "$a" 0 ] ]
    set b [ string trim [ string trim "$b" 0 ] ]
    return [expr ![ llength $a ] && ![ llength $b ] ]
}




------------------------------------------
Rusty Brooks : http://www.rustybrooks.org/
    Spewing wisdom from every orifice
------------------------------------------

Reply via email to