Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Memory leak when my application FGETS
Message
From
04/06/2001 16:24:53
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00512127
Message ID:
00514816
Views:
10
I found some old DOS code along the lines of what Vlad mentioned below, if it will be of help. The routine read a file and stripped printer codes from it for viewing purposes (my version of a print preview in DOS).

cViewIn=TMP_DIR+sys(3)+".vue"
copy file &cPrtFile to &cViewIn
nFH_In = fopen(cViewIn,2) && get filehandle
nFileSize = fseek(nFH_In,0,2) && file size
=fseek(nFH_In,0) && rewind file pointer
** read file to string and strip unwanted codes
nBytesLeft2Read=nFileSize

cViewOut=TMP_DIR+sys(3)+".OUT"
nFH_Out=fcreate(cViewOut)

do while .T.
cText = fread(nFH_In,min(16384,nBytesLeft2Read)) && 16k AT A TIME
cText = strtran(cText,RESET ,"")
=fwrite(nFH_Out,cText,len(cText)) && append to file with string
nBytesLeft2Read=nBytesLeft2Read-(min(16384,nBytesLeft2Read))
if nBytesLeft2Read<1
exit
endif
enddo .t.
=fclose(nFH_In) && close file
=fclose(nFH_Out) && close file

>Hi!
>
>You can also use FREAD(). If file is large, FiletoStr() might be not good idea to put entire file into a string in the memory. By using FREAD you will do the same in a loop.
>
>>Hi Vlad,
>>
>>I gave SYS(1104) a try but nothing changed in the words of physical memory leak. I'll try to re-write my code with the use of FILETOSTR(). Anyway, thanks for a hint.
>>
>>Przemek
Previous
Reply
Map
View

Click here to load this message in the networking platform