Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
EOF marker in csv, text files
Message
 
 
À
13/08/2001 07:49:37
Information générale
Forum:
Visual FoxPro
Catégorie:
FoxPro 2.x
Divers
Thread ID:
00542920
Message ID:
00542934
Vues:
36
Jason,
You can use the following program
*  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 it 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
In VFP 6 it can be done in a few lines of code
lcData = Filetostr("Myfile.csv")
IF ASC(RIGHT(lcData,1)) = 26    && make sure that its CTRL+Z
  = Strtofile(LEFT(lcData, LEN(lcData)-1), "Myfile.csv")
ENDIF
>I am trying to create a csv file from a foxprox table to be uploaded by another
>application.
>>The problem I have is when the csv file is created, thee is a EOF marker at the end.
>When this csv file is uploaded by the app., it crashes because it does not recognise the EOF marker.
>How can I remove the EOF marker when I am creating the csv file?
>thanks to anyone who can help me.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform