Kbase P136839: 4GL/ABL: How do I read a UNICODE text file in 4GL/ABL?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  11/3/2008 |
|
Status: Unverified
GOAL:
4GL/ABL: How do I read a UNICODE text file in 4GL/ABL?
GOAL:
How to read a UNICODE text file of unknown or unsupported code page using 4GL/ABL?
GOAL:
How to import data from a UNICODE text file of unknown or unsupported code page?
GOAL:
How to use Microsoft Word to read a UNICODE text file of unknown or unsupported code page?
GOAL:
How to import data from a UNICODE file of unknown and possibly unsupported code page using Microsoft Word?
GOAL:
How to use Microsoft Word to convert a UNICODE file of unknown and possibly unsupported code page into a text file using 4GL/ABL?
FACT(s) (Environment):
Windows
Progress 9.x
OpenEdge 10.x
FIX:
The following procedure reads a UNICODE file of unknown and possibly unsupported code page into Microsoft Word, saves the contents of the original file in another text file using the Microsoft Word SaveAs Method, and then processes the newly saved text file to import the data from the text file into an output file.
/* Define variables for original, converted and output file names */
DEFINE VARIABLE cOriginalFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cConvertedFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cOutputFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE wdFormatText AS INTEGER NO-UNDO.
/* Initialize the file names */
ASSIGN
cOriginalFileName = "C:\WRK91E\TI630.TXT"
cConvertedFileName = "C:\WRK91E\myfile.txt"
cOutputFileName = "C:\WRK91E\tools.txt"
wdFormatText = 2. /* SaveAs method parameter that saves file in Windws Text Format */
/* Open original file in Microsoft Word and save it as a text file */
DEFINE VARIABLE chWord AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chDoc AS COM-HANDLE NO-UNDO.
CREATE "Word.application" chWord.
chDoc = chWord:Documents:OPEN(cOriginalFileName).
chWord:ActiveDocument:SaveAs(cConvertedFileName,wdFormatText).
chWord:QUIT().
RELEASE OBJECT chWord.
/* Process the newly created text file */
DEFINE VARIABLE t-tool AS CHARACTER NO-UNDO.
DEFINE VARIABLE t-desc AS CHARACTER NO-UNDO.
DEFINE VARIABLE t-cav AS CHARACTER NO-UNDO.
INPUT FROM value(cConvertedFileName).
OUTPUT TO VALUE(cOutputFileName).
REPEAT:
IMPORT DELIMITER "," t-tool t-desc t-cav.
EXPORT DELIMITER "," t-tool t-desc t-cav.
END.
INPUT CLOSE.
OUTPUT CLOSE.