Reading/Writing unusual characters from text file

dwhite

Member
I have a need to store data such as this in a text file:

¯-a}vˆ—íU±/ƒ*Á0’…ÜÈ

When I was writing it to a text file I was using the EXPORT function and it was adding quotes around my value like so:

"¯-a}vˆ—íU±/ƒ*Á0’…ÜÈ"

so I switched to the PUT UNFORMATTED function to do it and the quotes went away.

My problem though is when I try to read the file, I'm doing it like so:

REPEAT:
IMPORT UNFORMAT allFileData.
allFileData = allFileData + newLine.
END.

INPUT CLOSE.

However, it won't read that line of data and I think it's because it has a character in it that looks like a quote (the ’ value).

I verified this by just trying to put the string into a character variable and use it and it won't work. It gives me a "unmatched quote found in procedure" error.

So my question is two fold. Is PUT UNFORMATTED the best way to write the data to a file so that the extra quotes aren't added? And is there a good way to properly get the data back out of that file in code?
 
Got it working doing this:

FILE-INFO:FILE-NAME = txtFile:SCREEN-VALUE.
SET-SIZE(allFileData) = FILE-INFO:FILE-SIZE.

INPUT FROM VALUE(txtFile:SCREEN-VALUE) BINARY NO-MAP NO-CONVERT.
IMPORT allFileData.
INPUT CLOSE.

where allFileData is a memptr.
 
Back
Top