I am trying to copy a table to a text file which is no problem at all. The problem I am running into is that I do not want a line feed or carriage return at the end of my text file. Any ideas on how to accomplish this?
While there is no way to suppress these characters, it easy to "kill" them off in VFP 6.0.
SET SAFETY OFF
copy to ... file.txt
lcTemp = filetostr( "file.txt" )
lcTemp = Left(lcTemp, LEN(lcTemp)-2)
strtofile(lcTemp, "file.txt"
SET SAFETY ON
I think that the suggestions above may work with V2.6 but if not low level file functions would allow you to manipulate the file -- check some of the examples in help or there have been a number of threads in the forum.
OK, here's on old program (written originally in FPD 2.0) that I used to strip off the final EOF character - also a problem for some non-DOS programs. You could make some minor changes to kill off the last 3 (?) characters which would include the CRLF (chr(13)+Chr(10)).
*!* STRIPASCIIEOF.PRG
LPARAMETERS qcFileName
* Open the file with unbuffered read/write access
lnhandle = FOPEN(qcFileName,12)
* Test for possible file opening error
IF lnhandle = -1
WAIT WINDOW "Error Opening File: " + ALLTRIM(qcFileName)TIMEOUT 10
RETURN
ENDIF
l_nSize = FSEEK(lnHandle,0,2) && Determine file size
= FSEEK(lnHandle, -1, 2) && Need to sneak a peak at the last character
l_nLastChar = INT(ASC(FREAD(lnHandle,1)))
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.