DEFINE VARIABLE lv-InputFileName AS CHARACTER NO-UNDO INITIAL "C:\Database\Live\icmasliv.df".
DEFINE VARIABLE lv-OutputFileName AS CHARACTER NO-UNDO INITIAL "C:\Database\Live\icmaslivnew.df".
DEFINE VARIABLE lv-Import AS CHARACTER NO-UNDO.
DEFINE VARIABLE lv-i AS INTEGER NO-UNDO.
DEFINE VARIABLE lv-j AS INTEGER NO-UNDO.
DEFINE VARIABLE lv-ObjectSeq AS INTEGER NO-UNDO INITIAL 1.
DEFINE VARIABLE lv-PropertySeq AS INTEGER NO-UNDO INITIAL 1.
DEFINE VARIABLE lv-Table AS CHARACTER NO-UNDO.
DEFINE VARIABLE lv-IndexArea AS CHARACTER NO-UNDO.
DEFINE TEMP-TABLE tt-Object NO-UNDO
FIELD Sequence AS INTEGER
FIELD ObjectType AS CHARACTER
FIELD ObjectName AS CHARACTER
FIELD TopLine AS CHARACTER
INDEX idxSeq IS PRIMARY Sequence.
DEFINE TEMP-TABLE tt-Property NO-UNDO
FIELD Sequence AS INTEGER
FIELD ObjectSequence AS INTEGER
FIELD PropertyName AS CHARACTER
FIELD PropertyValue AS CHARACTER
FIELD LineValue AS CHARACTER
INDEX idxSeq IS PRIMARY ObjectSequence Sequence.
DEFINE TEMP-TABLE tt-TableArea NO-UNDO
FIELD Area AS CHARACTER
FIELD TABLEName AS CHARACTER
FIELD SizeK AS CHARACTER
FIELD SIZE AS CHARACTER
FIELD RecordNo AS CHARACTER
FIELD MinSize AS CHARACTER
FIELD MaxSize AS CHARACTER
FIELD AvSize AS CHARACTER
FIELD OptRecsBlk AS CHARACTER
FIELD Col1 AS CHARACTER
FIELD StorageArea AS CHARACTER
FIELD Counter AS CHARACTER
FIELD Difference AS CHARACTER
FIELD Frag AS CHARACTER .
DEFINE BUFFER ParentTable FOR tt-Object.
DEFINE BUFFER ParentTableArea FOR tt-Property.
DEFINE STREAM s-in.
DEFINE STREAM s-out.
INPUT STREAM s-in FROM VALUE(lv-InputFileName).
REPEAT:
IMPORT STREAM s-in UNFORMATTED lv-Import.
CASE TRUE:
WHEN ENTRY(1,lv-Import," ") EQ "ADD" THEN
DO:
CREATE tt-Object.
ASSIGN
tt-Object.Sequence = lv-ObjectSeq
tt-Object.ObjectName = TRIM(ENTRY(3,lv-Import," "),"~"")
tt-Object.TopLine = lv-Import
tt-Object.ObjectType = ENTRY(2,lv-Import," ")
lv-ObjectSeq = lv-ObjectSeq + 1.
END.
OTHERWISE
DO:
CREATE tt-Property.
ASSIGN
tt-Property.ObjectSequence = tt-Object.Sequence
tt-Property.Sequence = lv-PropertySeq
tt-Property.PropertyName = TRIM(ENTRY(1,TRIM(lv-Import)," "))
tt-Property.PropertyValue = TRIM(lv-Import)
tt-Property.LineValue = lv-Import
lv-PropertySeq = lv-PropertySeq + 1.
ASSIGN
tt-Property.PropertyValue = TRIM(REPLACE(tt-Property.PropertyValue,tt-Property.PropertyName,""))
WHEN LENGTH(tt-Property.PropertyName) GT 0.
END.
END CASE.
END.
INPUT STREAM s-in CLOSE.
OUTPUT STREAM s-out TO value(lv-OutputFileName).
FOR EACH tt-Object:
PUT STREAM s-out UNFORMATTED tt-Object.TopLine SKIP.
FOR EACH tt-Property
WHERE tt-Property.ObjectSequence EQ tt-Object.Sequence:
PUT STREAM s-out UNFORMATTED tt-Property.LineValue SKIP.
END.
END.
OUTPUT STREAM s-out CLOSE.