Thanks Lowfatspread,
I didn't mention in my question that the field may contain a decimal point, but that's not your fault so I am going to give you the points.
I actually found a good answer (which I have successfully tested) that does consider the decimal point. It is on a website called www.sqrtools.com, created by an SQR guy called Tony Delia.
I will post it here in case it helps someone else in the future. Sorry, I see the indenting got lost in the copy/paste.
Again, thanks for your interest and help.
!*************************
!* *
!* MODULE: TDNUMBER.SQC *
!* AUTHOR: TONY DELIA. *
!* DATE: 09/09/97. *
!* SYSTEM: TD SQR UTILITY SERIES. *
!* DESC: NUMERIC VALIDATION ROUTINE. *
!* *
!*************************
!* *
!* USAGE: let $w-in = '0123456789' *
!* do TD-Numeric($w-in, $w-code) *
!* . *
!* let $w-in = 'HELLO' *
!* do TD-Numeric($w-in, $w-code) *
!* . *
!* let $w-in = '' *
!* do TD-Numeric($w-in, $w-code) *
!* . *
!* . *
!* . *
!* #Include 'tdnumber.sqc' *
!* *
!*************************
!* *
!* RESULTS: Example 1 returns 'Y' in $w-code (Numeric) *
!* Example 2 returns 'N' in $w-code (Non-Numeric) *
!* Example 3 returns 'E' in $w-code (Error - NULL) *
!* *
!*************************
!* *
!* LEGAL: CONFIDENTIALITY INFORMATION. *
!* *
!* This module is the original work of Tony DeLia. It *
!* can be considered ShareWare under the following *
!* conditions. *
!* *
!* A - The author's name (Tony DeLia) remains on any *
!* and all versions of this module. *
!* B - Any modifications must be clearly identified. *
!* C - A "vanilla" copy of this module must be kept *
!* alongside any revised versions. *
!* *
!*************************
!* *
!* WEBSITE: http://www.sqrtools.com *
!* *
!* Questions/Comments: tdelia@erols.com *
!* *
!*************************
let $NUMstring = '0123456789.' ! 0-9 (and 1 decimal)
let $NUMok = 'E'
let #NUMlen = length($NUMin)
let #NUMpos = 1
let #NUMdec = 0 ! First Decimal Pointer
let #NUMextra = 0 ! Extra Decimal Pointer
let #NUMdec = instr($NUMin, '.', 1)
if #NUMdec > 0
and #NUMdec < #NUMlen
let #NUMextra = instr($NUMin, '.', #NUMdec + 1)
end-if
if #NUMextra = 0
while #NUMpos <= #NUMlen
let $NUMok = 'Y'
let $NUM = substr($NUMin, #NUMpos, 1)
let #NUM = instr($NUMstring, $NUM, 1)
if #NUM = 0
let $NUMok = 'N' ! Non-Numeric Detected
let #NUMpos = #NUMlen ! Set Position to Length
end-if
let #NUMpos = #NUMpos + 1
end-while
end-if
end-procedure
Main Topics
Browse All Topics





by: LowfatspreadPosted on 2004-02-20 at 18:01:26ID: 10417602
? something like this
ld,#kount, 1),'0','9' ),0,1)
Declare-variable
integer #kount
integer #isnum
end-declare
let #kount = 1
let #isnum = 0
WHILE #kount < length(#yourfield)
let #isnum= #isnum + cond(range(substr(#yourfie
let #kount=#kount+1
end-while
if isnum = 0 then its an integer....
otherwise it contains nonnumeric characters...
you may need to use the ltrim and rtrim functions to remove leading and trailing spaces....
e.g.
rtrim(ltrim(#yourfield,' ') ,' ')
in place of the #yourfield spec above..
or you could write your own numeric test function in C and then reference it from brio...
the above is basically looping through the field 1 byte at a time testing to see if the byte contains a number
if it does then 0 is added to the #isnum variable if not its incremented by 1
so that at the end of the loop #isnum contains the number of non numeric characters present....
hth