Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to remove end-of-file marker in text files
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00349517
Message ID:
00349526
Views:
19
>How can I remove the EOF() marker in a text file created with SET ALTERNATE???
>
>I know I've seen this mentioned here before, but I can't search on "end of file" because the words are too short...
>
>TIA

Larry,
There is a program I wrote a while ago ...
*  Purpose  Remove Ctrl+Z (EOF) character from the end of the text file
*            usualy created by COPY SDF TO comment
*  Param's  The name of the file
*   Return  .T. if operation was sucessfull
PARAMETER pcFileName
IF NOT FILE(pcFileName)
	WAIT' ERROR: FILE '+pcFileName+' DOES NOT EXIST' WINDOW
	RETURN .F.
ENDIF

PRIVATE nHandle, nFileSize, cData, cNewSize, nIOError, lRet

* Open the file
nHandle  = FOPEN(pcFileName,2)
* Get its size
nNewSize = FSEEK(nHandle,-1,2)
*nFileSize = FSEEK(nHandle,0,2)
* Read the last byte of it
cData = FREAD(nHandle,1)

lRet = .T.

* Check if it's Ctrl+Z
IF ASC(cData) = 26
	IF FCHSIZE(nHandle, nNewSize) < 0
		nIOError = FERROR()
		WAIT 'ERROR WRITING TO FILE: '+ALLTRIM(STR(FERROR())) WINDOW
		lRet = .F.
	ENDIF
ENDIF

=FCLOSE(nHandle)

RETURN lRet
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform