PETER ZHOU
checking whether it's a numeric on a variable October 20, 2008 05:08AM |
Louis Verbraak
Re: checking whether it's a numeric on a variable October 20, 2008 09:08AM |
David Egan
Re: checking whether it's a numeric on a variable October 20, 2008 09:18AM |
Udo
Re: checking whether it's a numeric on a variable October 20, 2008 10:09AM |
PROCEDURE isNumeric(pWert) i is int x is int l_Num is boolean l_Maxfor is int IF pWert = "" THEN RESULT False l_Num = False l_Maxfor = Length(pWert) FOR i = 1 TO l_Maxfor //Length(pWert) x = Asc(pWert[[i]]) IF x = 45 OR x = 46 THEN // 45= - // 46= . (decimal point) ELSE IF x < 48 OR x > 57 THEN // only digits 0 ... 9 RESULT False END l_Num = True END END RESULT l_Num
PETER ZHOU
Re: checking whether it's a numeric on a variable October 20, 2008 11:09AM |
Quote
David Egan
Hi Peter
You could look at each character in the variable and use IsNumeric to check each one, something likelb_IsNum is boolean = true for i = 1 to length(varToCheck) if NOT IsNumeric(varToCheck[[i]]) THEN lb_IsNum = false BREAK END
HTH
David
PETER ZHOU
Re: checking whether it's a numeric on a variable October 20, 2008 11:09AM |
Quote
Udo
Hi Peter
write your own function. Here is a little code
PROCEDURE isNumeric(pWert) i is int x is int l_Num is boolean l_Maxfor is int IF pWert = "" THEN RESULT False l_Num = False l_Maxfor = Length(pWert) FOR i = 1 TO l_Maxfor //Length(pWert) x = Asc(pWert[[i]]) IF x = 45 OR x = 46 THEN // 45= - // 46= . (decimal point) ELSE IF x < 48 OR x > 57 THEN // only digits 0 ... 9 RESULT False END l_Num = True END END RESULT l_Num
Udo
"Michel HERRSCHER".pcs.crosspost
Re: Checking whether it's a numeric on a variable October 21, 2008 10:57AM |