Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with FGETS.
Message
De
19/09/2000 10:19:13
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
19/09/2000 09:59:27
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00418031
Message ID:
00418040
Vues:
23
>Has anyone found this problem with FGETS (and possibly a work-around). To get FGETS to read more than 254 characters, you have to supply a second parameter of the number of bytes to use. If I set it to 257 or greater I get a Foxpro exception error C0000005. Any help would be much appreciated.


Andrew,
It has been partially corrected in VFP6 SP3 and now works up to 8192 chars. My workaround was to write my own fgets() :
function safegetline
lparameters handle
if type('handle')#'N' or handle<0
 return .f.
endif
lnCurPos = fseek(handle,0,1) && Save current pos
lcPortion = fread(handle,65536) && read in 64K blocks
lnNLPos = at(chr(13)+chr(10),lcPortion) && NL position
do while lnNLPos = 0 and !feof(handle)
  lcPortion = lcPortion + fread(handle,65536)
  lnNLPos = at(chr(13)+chr(10),lcPortion) && NL position
enddo
if lnNLPos>0  && If NL chars encountered
  retline = left(lcPortion, lnNLPos-1)
  =fseek(handle,lnCurPos+lnNLPos+1,0) && Set position to just after NL
else
  retline = lcPortion
endif
return retline
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform