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

Re: SQR command to distinguish alpha characters from aplha-numer



you could use the 'instr' function...
it returns the numeric position of a substring y in string x,
and returns 0 if not found.

hence...

let $S=<your string>
let #i=0
let #alpha=1
while #i<10 and #alpha=1
  if instr($S,to_char(#i),1)<>0
    let #alpha=0
end-while

of course this could be slower than just
searching through the string for the
first numeric character.
that would look like this:

let $S=<your string>
let #i=0
let #alpha=1
while #i<length($S) and #alpha=1
  let $c=substr($S,#i,1)
  if $c>='0' and $c<='9'
    let #alpha=0
  end-if
end-while


(kris)janis p. gale
hrsd - federal reserve bank of new york
x8163

>>> Zubin Shroff <zshroff@DTTUS.COM> Monday, July 12, 1999 6:49:32 PM >>>
     Is there an SQR command that can be used to interrogate a field and
     determine whether all characters are alphabets or alpha-numeric?

     e.g. Given 2 field values of 'JOB' and 'JOB9', we need to determine
     that JOB is alpha-only and JOB9 is alpha-numeric.

     Just wondering if there is an easier way than to read each character
     and look for the first non-alpha character