[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: checking for numeric chars
Oops, sorry, here I thought I was asking a simple thing, and I wasn't clear...
I want to check if a given character in a string is numeric. So I am
already looping thru the string and grabbing individual charactes, now I
want to figure out if they are numeric...
At 03:15 PM 2/11/02 -0700, Alan Ljungberg wrote:
>Do you want to determine if only a single character is numeric then i would
>evaluate if the ascii value is beween 048 and , 057. 048 and , 057 are the
>ascii values for 0 and 9 , if the acsii value is any value between the
>character is numeric. This will work for numeric characters in CHAR
>fields.
This is what I want to do - but I'd rather not check against ASCII codes,
this seems cryptic and hard to maintain.
The idea I had was
if $char = to_char(to_number($char)
Someone suggested in private email I use translate...
if Translate($char,'1234567890','X') = 'X'
! then char is numeric
else
! not numeric
end-if
this is certainly a good use of translate...
so which one is "better"? Quicker? more elegant?
any other ideas?
DTH
David Thompson-Hall 1210 W. Dayton St.
Programmer/Analyst Madison, WI 53706
Apps Tech/Operational Support Apps 608/265-9571
Div of Info Technology (DoIT)
University of Wisconsin-Madison david.thompson-hall@doit.wisc.edu