Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
\\ version 2
|
||||
Module Checkit {
|
||||
function global isNumber(a$, de$=".") {
|
||||
=false=true ' return boolean
|
||||
if de$="" then de$=str$(.1,".") ' get current decimal point character
|
||||
a$=trim$(ucase$(a$))
|
||||
m=len(a$)
|
||||
if m=0 then exit
|
||||
c$=filter$(a$,"0123456789")
|
||||
if c$ = "" then {
|
||||
=true
|
||||
} else.if m>1 then {
|
||||
\ may have -+ and ,
|
||||
if m=2 then {
|
||||
if not c$~"[-+\"+de$+"]" then break
|
||||
} else {
|
||||
if left$(c$,1 ) ~"[+-]" then c$=mid$(c$, 2)
|
||||
if not (c$=de$ or c$=de$+"E" or c$ ~ de$+"E[+-]") then break
|
||||
if c$ ~ de$+"E[+-]" then if not (instr(a$,"E+")>0 or instr(a$,"E-")>0) then break
|
||||
}
|
||||
if de$<>"." then a$=replace$(de$, ".", a$, 1,1)
|
||||
try {inline "a="+a$+"=="+a$}
|
||||
if valid(a) then =a = true=true ' return boolean
|
||||
}
|
||||
}
|
||||
Print isNumber("+1"), isnumber("-1"), isNumber("1+")=false, isnumber("1-")=false
|
||||
Print isNumber(",1",","), isnumber("1,",","), isNumber(",0",","), isnumber("0,", ",")
|
||||
Print isNumber(".1"), isnumber("1."), isNumber(".0"), isnumber("0.")
|
||||
Print isNumber("+.1"), isnumber("-1."), isNumber(".12e+232"), isnumber("0.122e10")
|
||||
Print isNumber("+.1a")=false, isnumber("asasa1212")=false, isNumber("1.2e43+23")=false, isnumber("0.122e10")
|
||||
Print isNumber("1221.211.1221")=false, isnumber("1221e1212")=false, isNumber("1.2e4323")=false, isnumber("-.122e-10")
|
||||
}
|
||||
Checkit
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
Function IsNumeric(a$) {
|
||||
def m
|
||||
=val(false->boolean)
|
||||
Try {
|
||||
if islet then {
|
||||
z=val(a$,letter$, m)
|
||||
} else.if isnum then {
|
||||
z=val(a$,number, m)
|
||||
} else z=val(a$,"", m)
|
||||
=m>len(a$)
|
||||
}
|
||||
}
|
||||
Function IsIntegerNumeric(a$) {
|
||||
def m
|
||||
=val(false->boolean)
|
||||
Try {
|
||||
z=val(a$,"Int", m)
|
||||
=m>len(a$)
|
||||
}
|
||||
}
|
||||
|
||||
Locale 1033 ' to use . as decimal, else we have to place 1033 or "." as second parameter
|
||||
|
||||
Print isNumeric("+1"), isNumeric("-1"), isNumeric("1+")=false, isNumeric("1-")=false
|
||||
Print isNumeric(",1",","), isNumeric("1,",","), isNumeric(",0",","), isNumeric("0,", ",")
|
||||
Print isNumeric(".1"), isNumeric("1."), isNumeric(".0"), isNumeric("0.")
|
||||
Print isNumeric("+.1"), isNumeric("-1."), isNumeric(".12e+232"), isNumeric("0.122e10")
|
||||
Print isNumeric("+.1a")=false, isNumeric("asasa1212")=false, isNumeric("1.2e43+23")=false, isNumeric("0.122e10")
|
||||
Print isNumeric("1221.211.1221")=false, isNumeric("1221e1212")=false, isNumeric("1.2e4323")=false, isNumeric("-.122e-10")
|
||||
Loading…
Add table
Add a link
Reference in a new issue