Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Limit of FGETS()
Message
De
30/11/2005 17:31:46
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
30/11/2005 16:25:34
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 7 SP1
Divers
Thread ID:
01073305
Message ID:
01073501
Vues:
17
>How could I get an entire text line into a string using that?

Something like this:
#Define CRLF Chr(13)+Chr(10)
Local lnHandle,lnLine
lnHandle = Fopen(Getfile('TXT'))
lnLine = 0
Do While !Feof(m.lnHandle)
  lnLine = m.lnLine + 1
  ? m.lnLine,FgetsSafe(m.lnHandle)
Enddo
Fclose(m.lnHandle)

Procedure FgetsSafe
  Lparameters handle
  If Type('m.handle')#'N' Or m.handle<0
    Return ''
  Endif
  Local lnCurPos,lnFileSize,lcPortion,lnNLPos,retline
  lnCurPos = Fseek(m.handle,0,1) && Save current pos
  lcPortion = Fread(m.handle,65500+255) && 65500 is max allowed recsize and 255 is fcount limit
  lnNLPos = Min(At(Chr(13),m.lcPortion), At(Chr(10),m.lcPortion)) && NL position
  If m.lnNLPos>0  && If NL chars encountered
    retline = Left(m.lcPortion, m.lnNLPos-1)
    =Fseek(m.handle,m.lnCurPos+m.lnNLPos,0) && Set position to just after NL
    If !(Fread(m.handle,1)$CRLF)
      =Fseek(m.handle,-1,1)
    Endif
  Else
    retline = m.lcPortion
  Endif
  Return m.retline
Endproc
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
Répondre
Fil
Voir

Click here to load this message in the networking platform