Consultor Eletrônico



Kbase P123977: 4GL: How to prepend the date at the begining of each line of a database log file?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   21/05/2007
Status: Unverified

GOAL:

4GL: How to prepend the date at the beginning of each line of a database log file?

FACT(s) (Environment):

OpenEdge Category: Language (4GL/ABL)
All Supported Operating Systems
Progress 9.x
Progress 8.x

FIX:

The following procedure takes a Progress database log file as input, appends the date to the beginning of each line, except blank and header lines, and outputs the data to a new file. Please note that starting with OpenEdge 10.1A the database log file format was changed to include the date in each line.
DEFINE VARIABLE cSourceFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cTargetFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cCurrentLine AS CHARACTER NO-UNDO.
DEFINE VARIABLE cCurrentTrim AS CHARACTER NO-UNDO.
DEFINE VARIABLE iLineLength AS INTEGER NO-UNDO.
DEFINE VARIABLE iTrimLength AS INTEGER NO-UNDO.
DEFINE VARIABLE cCurrentHeader AS CHARACTER NO-UNDO.
DEFINE VARIABLE cHeaderPrefix AS CHARACTER NO-UNDO.
DEFINE VARIABLE lIsHeader AS LOGICAL NO-UNDO.
ASSIGN
cSourceFileName = "C:\WRK91E\Sports2000.lg"
cTargetFileName = "C:\WRK91E\ModifiedSports2000.lg".
INPUT FROM VALUE ( cSourceFileName ).
OUTPUT TO VALUE ( cTargetFileName ).
REPEAT:
IMPORT UNFORMATTED cCurrentLine.
ASSIGN
cCurrentTrim = TRIM(cCurrentLine)
iLineLength = LENGTH(cCurrentLine)
iTrimLength = LENGTH(cCurrentTrim)
lIsHeader = (iLineLength NE iTrimLength) AND (iTrimLength > 0).
IF lIsHeader THEN DO:
cHeaderPrefix = SUBSTRING(cCurrentTrim, 1, 10) + " " + SUBSTRING(cCurrentTrim,21, 26) + " ".
PUT UNFORMATTED cCurrentLine SKIP.
NEXT.
END.
IF iTrimLength = 0 THEN DO:
PUT UNFORMATTED " " SKIP.
NEXT.
END.
ASSIGN
cCurrentLine = cHeaderPrefix + cCurrentLine.
PUT UNFORMATTED cCurrentLine SKIP.
END.
INPUT CLOSE.
OUTPUT CLOSE.