Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why doesn't text file have an end od file marker?

Status
Not open for further replies.

drosenkranz

Programmer
Sep 13, 2000
360
US
I'm working with a text file that comes my way from another agency that's trying to give us a text file for importing into an old DOS program called Metafile (don't ask) The file contains the "end or record" markers but ther is no "end of file marker". This is crashing the Metafile import operation.

COPY TO REDDB.DBF TYPE FOX2X (We also tried excluding this line- no diff)
CLOSE ALL
USE REDDB
COPY TO A:REDRAW.TXT SDF

We went into DOS and tryed to place an eof marker at the end of file but it would not save with the file. (We can do this with other old text files.) Is this eof character an issue with the codepage? If not, how do we get an eof marker on the text file we're generating from a FoxPro table using COPY TO ... SDF ?

 
In VFP 6.0, after you do your copy SDF, you could add the following:
lcFile = FILETOSTR("A:REDRAW.TXT")
IF ASC(RIGHT(lcFile, 1)) <> 0x1A &amp;&amp; ASCII eof [or CHR(26)]
lcFile = lcFile + CHR(0x1A)
SET SAFETY OFF
lnLength = STRTOFILE(lcFile, &quot;A:REDRAW.TXT&quot;)
SET SAFETY ON
ENDIF
lcFile = &quot;&quot; &amp;&amp; release all the space JIC (just in case)

Note: If I was really doing this, I'd actually do the copy SDF to a local disk temp directory, and then copy the file, after running the above, to the floppy. (You really wouldn't want to write to the floppy, read it back, then write it out again.)

Also, if you need to do this in other than 6.0, a similar (though longer) routine could be written using the low-level I/O functions (FOPEN(), FSEEK(), FWRITE(), FCLOSE()).

Rick

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top