function isnum(str:string):boolean; var i:integer; begin for i:=1 to length(str) do if not (str[i] in ['0'..'9']) then begin result:=false; exit; end; result:=true; end;
也可以作如下定义:
function IsDigit(S:String):Boolean; var i,j:integer; begin Result:=True; j:=0 ; for i:=1 to length(s) do begin if not (s[i] in ['0'..'9','.'])then Result:=False; if s[i]='.' Then j:=j+1; end; if j>1 then Result:=False; if (s[1]='.') or (s[length(s)]='.') then Result:=False; s:=copy(s,1, pos('.', S)-1); j:=0; for i:=1 to length(s) do begin if s[I]=’0’ then j:=j+1; end; if j>1 then Result:=False; end;