Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FSEEK() problems
Message
De
21/04/2003 08:41:57
 
 
À
21/04/2003 08:34:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00779708
Message ID:
00779724
Vues:
17
Here is the code I am attempting (note that I split the text file into 4 700MB files and the fseek() works, but I would like to keep it in one file, if possible)
gnFileHandle = FOPEN("tapes1212.dat")
* Seek to end of file to determine the number of bytes in the file
nSize =  FSEEK(gnFileHandle, 0, 2)     && Move pointer to EOF

IF nSize <= 0
	* If the file is empty, display an error message
	WAIT WINDOW "This file is empty!" NOWAIT
ELSE

	* If file is not empty, the program stores its contents
	* in memory, then displays the text on the main Visual FoxPro window
	IF lCheck <> 'Y'
		FOR X =0 TO nSize STEP 2264
			= FSEEK(gnFileHandle, X)      && Move pointer to BOF
			cString = FREAD(gnFileHandle, 2264)
etc. etc. I process the data that comes in from here
endfor
endif
Thanks!


>Amanda, just to be clear - there are two parameters after the file handle - the number of bytes to move and the relative from position from which to move. To position at the end of the file you would issue:
>
>
>gnPosition = FSEEK(gnFileHandle, 0, 2)  &&  Move 0 bytes from the end of the file 2
>
>
>In your original post you were only passing one parameter after the file handle which was the number of bytes to move. If you do not specify the relative from position it defaults to from the start.
>
>If this still does work then please post your exact code here for us to see.
>
>Also, are you checking that the FOPEN() was succesfull by checking the returned file handle?
>
>
>>I just tried that and it is still returning 0. Any other thoughts?
>>
>>Thanks!!
>>
>>>The last (3) parametr must be set to 2, if You set this parametr to 0 You always go to the begin file !!!.
>>>
>>> parameter 0 - go to begin
>>> 1 - current file pointer position
>>> 2 - go end file
>>>
>>> wrong !!!! gnPosition = FSEEK(gnFileHandle, 0) // nothing do
>>> good gnPosition = FSEEK(gnFileHandle, 0, 2) // end of file
>>>
"In three words I can sum up everything I've learned about life : it goes on." - R. Frost

Amanda Brown
Supervisor/Programmer
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform