[Source] Yet another IsNumeric() function [All OS]
Posted: Wed Jun 04, 2025 7:42 pm
I didnt post anything for quite a while (bc. rl stuff) so here we go.
Maybe this is useful to someone, have fun
Edit:
Updated Code here: viewtopic.php?p=641661#p641661
Code (old - dont use!):
Maybe this is useful to someone, have fun

Edit:
Updated Code here: viewtopic.php?p=641661#p641661
Code (old - dont use!):
Code: Select all
EnableExplicit
;Yet another IsNumeric() function!
;Author: Mijikai
Procedure.b IsNumeric(*c.Character,d.i)
Static.s p
Static.Character *p
Protected.Character *m
Protected.i e,t,l
p = "0123456789.-"
*p = @p
*m = *p
If *c
If *c\c <> 0 And *c\c <> '.'
If *c\c = '-'
*c + 2
If *c\c <> 0 And *c\c <> '.'
e = '-'
EndIf
Else
e = '-'
EndIf
If e
If d = 0
e = '.'
EndIf
While *c\c <> 0
While *m\c <> e
If *m\c = *c\c
If *m\c = '.'
e = '.'
EndIf
t + 1
Break
EndIf
*m + 2
Wend
*m = *p
*c + 2
l + 1
Wend
*c - 2
If t = l And *c\c <> '.'
ProcedureReturn #True
EndIf
EndIf
EndIf
EndIf
ProcedureReturn #False
EndProcedure
Procedure.i main();Example
Protected.s a,b
a = "-10";<- numbers can be positive or negativ
b = "1.0";<- optionally it can be a number with a dot '.'
Debug IsNumeric(@a,0);<- just a number no other symbols expected
Debug IsNumeric(@b,1);<- set d to 1 if the number may contain a '.'
;Note:
;- No support for ',' instead of '.' (usually we use '.' for floats/doubles)
;- No support for notation ex. 'e-20'
EndProcedure
End main()