Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Limit of FGETS()
Message
 
To
30/11/2005 12:23:59
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 7 SP1
Miscellaneous
Thread ID:
01073305
Message ID:
01073460
Views:
14
>Help says the limit of FGETS() is 8192 characters. Is there a way to get around this limit?
>
>TIA!
It depend how big is the file. But if one line is more then 8192b I suppose it is huge :-)

Based on Cetin's anser:
#define BYTES_TO_READ 16384 && Or whatever

lnFileHandler = FOPEN("MyHugeFile.TXT")
IF lnFileHandler < 0
   RETURN
ENDIF
LOCAL lcText, lnAT, lcLine
m.lcText = []
DO WHILE NOT FEOF(lnFileHandler)
   m.lcText = m.lcText + FREAD(lnFileHandler, BYTES_TO_READ)
   lnAT = AT(CHR(13),m.lcText)
   DO WHILE lnAT # 0
      m.lcLine = LEFT(m.lcText, lnAT-1) && The Line w/o CR
      ProcessLine(m.lcLine) && Do something with the line
      m.lcText = SUBSTR(m.lcText, lnAt+2) && To Skip LineFieed (CHR(10)) If any, if not just change this line to lnAT+1
      lnAT = AT(CHR(13),m.lcText)  
   ENDDO
ENDDO
IF NOT EMPTY(m.lcText)
   ProcessLine(m.lcText) && Process the final string if it is not empty
ENDIF
(not tested)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform