[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

RE: [sqr-users] How to check 'CHAR' field to find out ifitcontainsall Numeric?




Actually, I think Kevin is right.  Kevin's way returns the correct output, but 
your way seems to always say the string contains letters.

The code below shows this as the output:
-------------
Kevin's way
-------------
123124 All numeric
ABCDEF Contains non-numeric characters
-------------
Tchaha's way
-------------
123124 Contains non-numeric characters
ABCDEF Contains non-numeric characters

Here is the code:

show '-------------'
show 'Kevin''s way'
show '-------------'

let $string = '123124'
show $string noline
if $string <> '' and translate($string, '0123456789', '') = ''
  show ' All numeric'
else
  show ' Contains non-numeric characters'
end-if

let $string = 'ABCDEF'
show $string noline
if $string <> '' and translate($string, '0123456789', '') = ''
  show ' All numeric'
else
  show ' Contains non-numeric characters'
end-if

show '-------------'
show 'Tchaha''s way'
show '-------------'

let $string = '123124'
show $string noline
if $string <> '' and translate($string, '','0123456789') = ''
  show ' All numeric'
else
  show ' Contains non-numeric characters'
end-if

let $string = 'ABCDEF'
show $string noline
if $string <> '' and translate($string, '','0123456789') = ''
  show ' All numeric'
else
  show ' Contains non-numeric characters'
end-if






-----------------------------------------------------
James Harris
Junior Systems Programmer/Analyst
Information Technology Division
Frederick Community College
-----------------------------------------------------


_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users