I'm trying to simply check whether a CHARACTER field has only NUMERIC values. E.g., whether a 5-position zip-code field has all digits. I don't see any such a test or FUNCTION in the OE reference works.
You could do something like the below. There are alternatives, mainly centered around reading each character and checking that they're individual integers but that's lots more code.
Def var iCheckVal as int.
iCheckVal = int(cZipCode) no-error.
if error-status:error then
/*do some error handling */ .
Or a slightly more modern approach
Def var iCheckVal as int.
Do on error undo, throw:
iCheckVal = int(cZipCode).
/* might be better to check SysErr and e.GetMessageNumber(1)*/
Catch e as progress.lang.error.
/*do some error handling */
End catch.
End.
-- peter
OE10.2B GUI client?
I'm sure that I could be solved either using a .NET RegEx or a System.Convert method.
Check out http://www.oehive.org/project/isNumber
Peter, Mike, Thomas:
With regard to your suggestions, they will not solve my problem in the
case of a zip code whose value is, e.g., " 345 ", where the 5-byte field
has a leading and/or trailing blank. The INTEGER function will not yield
an error condition, since it converts this to the integer 345. What I did
meanwhile was to check byte-by-byte for a blank. (I didn't mention that
this is not a vb.net programming question; rather, a good old Progress
procedure question.)
I'm an old COBOL programmer, where the "IS NUMERIC" test is what I used to
use. I'm really surprised that such a basic function is missing from the
Progress language.
David Wolf
Senior Programmer
Eastern Savings Bank fsb
410-568-6114 (direct line)
410-568-4474 (fax)
From:
Mike Fechner
To:
David Wolf
Date:
07/20/2011 10:46 AM
Subject:
New message: "NUMERIC test or FUNCTION"
David Wolf,
A new message was posted in the thread "NUMERIC test or FUNCTION":
http://communities.progress.com/pcom/message/132988#132988
Author : Mike Fechner
Profile : http://communities.progress.com/pcom/people/mikefe
Message:
e for a blank. (I didn't mention that
this is not a vb.net programming question; rather, a good old Progress
procedure question.)
David, I did not mention VB.NET at all. Starting 10.2A you can use .NET classes directly from the ABL, check the docs for the GUI for .NET feature.
You might need to replace space with some letter then try the conversion process.