RosettaCodeData/Task/Determine-if-a-string-is-numeric/RapidQ/determine-if-a-string-is-numeric.rapidq
2015-02-20 00:35:01 -05:00

49 lines
1.1 KiB
Text

isnumeric
$Typecheck on
Defint FALSE, TRUE
FALSE = 0
TRUE = NOT FALSE
Function isNumeric(s as string, optchar as string) as integer
If len(s) = 0 then
Result = FALSE
Exit Function
End If
if instr(s,"+") > 1 then
Result = FALSE
exit function
end if
if instr(s,"-") > 1 then
Result = FALSE
exit function
end if
Defint i, ndex = 0
For i = 1 to len(s)
select case asc(mid$(s,i,1))
case 43 '+
case 45 '-
case 46 '.
if ndex = 1 then
Result = FALSE
Exit function
end if
ndex = 1
case 48 to 57 '0 to 9
case else
if instr(optchar,(mid$(s,i,1))) = 0 then
Result = FALSE
exit function
end if
end select
next
Result = TRUE
End Function
'============================================================
'Begin
'============================================================
showmessage (str$(isNumeric("-152.34","")))
end