Consultor Eletrônico



Kbase P20822: How to convert all Progress 4GL keywords in a procedure file to upper/lower case without WebSpeed Wo
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   17/11/2009
Status: Verified

GOAL:

Is there a tool to convert all Progress 4GL keywords in a procedure file to upper or lower case at once ?

GOAL:

Is there a beauty.p tool for releases later than Progress 6 ?

GOAL:

How to convert all Progress 4GL keywords in a procedure file to upper/lower case without WebSpeed Workshop ?

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x
All Supported Operating Systems

FIX:

If you have access to the WebSpeed Workshop (By installing WebSpeed or a ProVISION plus license for example), you can use the WebTools. From the AppBuilder, go to Tools -> WebTools. Your web browser should pop up. From there, go to Application Manager -> Code Utils and select Beautify from the drop-down menu.

If you do not have the WebSpeed Workshop, you can write a parsing tool based on the 4GL functions KEYWORD and KEYWORD-ALL.

An example of how to do this would be:

/* keywordfinder.p
Finds Progress 4GL keywords in an ASCII file and replaces them with
unabbreviated capitalized equivalent */
DEFINE VARIABLE cInputFile AS CHARACTER FORMAT "X(50)" NO-UNDO.
DEFINE VARIABLE cOutputFile AS CHARACTER FORMAT "X(50)" NO-UNDO.
DEFINE VARIABLE cLine AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCounter1 AS INTEGER NO-UNDO.
DEFINE VARIABLE iCounter2 AS INTEGER NO-UNDO.
DEFINE VARIABLE cTemp AS CHARACTER NO-UNDO.

DEFINE STREAM incoming.
DEFINE STREAM parsed.

UPDATE cInputFile cOutputFile.

INPUT STREAM incoming FROM VALUE(cInputFile).
OUTPUT STREAM parsed TO VALUE(cOutputFile).

REPEAT:
IMPORT STREAM incoming UNFORMATTED cLine.

DO iCounter1 = 1 TO NUM-ENTRIES(cLine," "): /* Read line word by word */
cTemp = ENTRY(iCounter1,cLine," ").
DO iCounter2 = 1 TO NUM-ENTRIES(cTemp,":"): /* catch attribute references */
/* It's a keyword ? */
IF KEYWORD-ALL(ENTRY(iCounter2,cTemp,":")) <> ? THEN
/* then replace it with unabbreviated, capitalized keyword */
ENTRY(iCounter2,cTemp,":") = KEYWORD-ALL(ENTRY(iCounter2,cTemp,":")).
END.

ENTRY(iCounter1,cLine," ") = cTemp. /* Put parsed string back in line */
END.

PUT STREAM parsed UNFORMATTED cLine.
END.

OUTPUT STREAM parsed CLOSE.
INPUT STREAM incoming CLOSE.

Be aware that this sample code is very basic. It will not replace all keywords ("no-error." will not be caught since the period isn't handled) , and it will replace some keywords incorrectly ("FORM" will become "FORMAT" when it shouldn't).
You will most likely have to expand it to carry the desired functionality.