Consultor Eletrônico



Kbase P138854: The size of an output file does not match the number of characters exported to it
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   1/30/2009
Status: Unverified

SYMPTOM(s):

The size of an output file does not match the number of characters exported to it


The file 4 bytes larger than expected

FACT(s) (Environment):

Progress 9.1E
OpenEdge 10.1C
Text was sent to a text file using the Export method
Text was exported the document using source code such as the one below:
DEFINE VARIABLE <variable1> as CHARACTER. DEFINE VARIABLE <variable2>as CHARACTER. DEFINE VARIABLE <variable3> as CHARACTER. DEFINE VARIABLE <variable4> as CHARACTER. OUTPUT TO "<output_file>".export STRING(<variable1>,"X(400)") + STRING(<variable2>,"X(400)") + STRING(<variable3>,"X(400)") + STRING(<variable4>,"X(20)").OUTPUT CLOSE.

CAUSE:

the Export method always includes 1 opening quote (1 character), 1 closing quote (1 character) and 1 carriage return (2 characters, because Windows carriage returns are represented by ASCII characters 10 and 13 together).

FIX:

Using COPY-LOB instead of Export generates a file with the correct size. The code below is an example of how such code can be written.
/*Define your variables*/ DEFINE VARIABLE fullOutput AS LONGCHAR. DEFINE VARIABLE <variable1> as CHARACTER. DEFINE VARIABLE <variable2>as CHARACTER. DEFINE VARIABLE <variable3> as CHARACTER. DEFINE VARIABLE <variable4> as CHARACTER. /*Place your variable strings inside a fullOutput LONGCHAR*/ fullOutput = STRING(<variable1>,"X(400)") + STRING(<variable2>,"X(400)") + STRING(<variable3>,"X(400)") + STRING(<variable4>,"X(20)"). /*Create an empty data file*/ OUTPUT TO "<output_file>". OUTPUT CLOSE. /*Do a copy-large-object of your longchar into the text file*/ COPY-LOB FROM fullOutput TO FILE "<output_file>".