Consultor Eletrônico



Kbase P107303: How to read a text file with NULL '\0' character terminators.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   8/5/2005
Status: Unverified

GOAL:

How to read a text file with NULL '\0' character terminators.

GOAL:

How to read a file with embedded NULL characters.

FIX:


Use READKEY to read the file character by character. For example:

INPUT FROM j:\slashNull.txt.
OUTPUT TO "e:\temp\testfil.txt".

DEFINE VARIABLE wx-line AS CHARACTER NO-UNDO.

REPEAT:
wx-line = "".
REPEAT:
readkey pause 0.
IF lastkey = 00 THEN
wx-line = wx-line + " ". /* Replace NULL with space */
ELSE
wx-line = wx-line + CHR(lastkey).

IF lastkey = 13 THEN leave. /* CR */
IF lastkey = -2 THEN leave. /* EOF */
END.
PUT UNFORMATTED wx-line SKIP.
F lastkey = -2 THEN leave.
END.

INPUT CLOSE.
OUTPUT CLOSE.