Hello,
I just wanted to know, if there is a Progress-Function, that checks a string, whether it fits a specific fomat, or if you have such a Function, or if I have to make it on my own?
I want to give 2 parameters (or 3, because i know the datatype) (1. the string to check, 2. the format ) and want to get a logical output.
The format is given in Progress format (eg. "x(9)" or "->>.>>>.>99").
(string x format = logical)
An example for what I mean is that:
define var l_matchesformat as log.
l_matchesformat = check_format("assf", "x(5)") /* would return TRUE*/
l_matchesformat = check_format("assf", "x(3)") /* would return FALSE*/
l_matchesformat = check_format("assf", "999") /* would return FALSE*/
l_matchesformat = check_format("151,25", "->>.>>>.>>9,99") /* would return TRUE*/
I hope you understand what I mean and I want to thank you for reading till here
PS.: Sorry for my English, I am German
Message was edited by:
Konstantin Helbig
Hallo Herr Helbig,
as far as I know, there is no such ready built function. But it can't be to hard to build it. You might need to look as this per data-type, need different functions for each data-type. This could be achieved using polymorphism and static methods in a class (10.1C).
For numeric data-types you should use the STRING function with NO-ERROR and check the ERROR-STATUS:ERROR and ERROR-STATUS:NUM-MESSAGES.
For character data, maybe creating a second string might be a solution:
METHOD STATIC LOGICAL StringMatchesFormat (pcSourceString AS CHARACTER, pcFormatString AS CHARACTER):
DEFINE VARIABLE cTargetString AS CHARACTER NO-UNDO.
cTargetString = STRING(pcSourceString, pcFormatString).
IF TRIM(cTargetString) <> TRIM(pcSourceString) THEN RETURN FALSE.
RETURN TRUE.
END METHOD.