ad_page_contract_filter_proc_naturalnum (public)

 ad_page_contract_filter_proc_naturalnum name value_varname

Defined in packages/acs-tcl/tcl/tcl-documentation-procs.tcl

Checks whether the value is a valid integer >= 0, and removes any leading zeros so as not to confuse Tcl into thinking it's octal.

Parameters:
name
value_varname
Author:
Lars Pind <lars@pinds.com>
Created:
25 July 2000

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_page_contract_filters ad_page_contract_filters (test acs-tcl) ad_page_contract_filter_proc_naturalnum ad_page_contract_filter_proc_naturalnum test_ad_page_contract_filters->ad_page_contract_filter_proc_naturalnum _ _ (public) ad_page_contract_filter_proc_naturalnum->_ ad_complain ad_complain (public) ad_page_contract_filter_proc_naturalnum->ad_complain

Testcases:
ad_page_contract_filters
Source code:
upvar $value_varname value


    # We can't really use "string is integer -strict", since it allows
    # numbers, which are invalid for e.g. SQL... e.g. "0x40".
    #
    # First a simple quick check to avoid the slow regexp
    # if {[string is integer -strict $value] && $value >= 0} {
    #    return 1
    # }

    # Check with leading zeros, but no "-" allowed, so it must be positive
    if { [regexp {^(0*)([1-9][0-9]*|0)$} $value match zeros value] } {
        if {[string is integer -strict $value]} {
            return 1
        }
    }

    ad_complain [_ acs-tcl.lt_name_is_not_a_natural]
    return 0
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: