Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel - find
Message
De
12/10/2004 07:18:05
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
10/10/2004 12:42:39
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Divers
Thread ID:
00948975
Message ID:
00950628
Vues:
10
>Cetin:
>
>I have taken your first suggestion and modified it. I am having a problem that I hope you can help with. There are 2 items that I am searching lcfile for: lcjoint, and lcsearchtext. Once Lcjoint is found, I want to continue the search in lcfile from that point to find lcsearchtext, not from the beginning of lcfile. Right now, it finds the occurrence of lcsearchtext from the beginning of the file. Any ideas? Thanks.
>
>lnlines = ALINES(arrlines, FILETOSTR(lcfile))
> IF ATCline(lcjoint, FILETOSTR(lcfile))<>0 &&found joint line
> ix = ATCline(lcsearchtext, FILETOSTR(lcfile))
> IF m.ix + m.rowoffsett =< m.lnlines &&check if offsett is in range
>
> *perform some calculations
>
> ENDIF
> ENDIF

Paul,
2 ways here (it's VFP not me providing many ways:)
lcFile = "myFile.txt"
lcJoint = "my joint text"
lcSearchText = "my search text"

Clear
? "Doing search 1"
Search1(m.lcFile, m.lcJoint, m.lcSearchText)
?
?
? "Doing search 2"
Search2(m.lcFile, m.lcJoint, m.lcSearchText)

Function Search1(tcFile, tcJoint, tcSearchText)
  * no Memowidth setting - supports lines over 1024
  Local Array arrLines[1]
  Local ix,jx,lnLines
  lnLines = Alines(arrLines, Filetostr(m.tcFile))
  For ix=1 To lnLines
    If Atc(m.tcJoint,arrLines[m.ix]) > 0 && Found start point
      ? m.tcJoint +"found on line#",m.ix
      ? arrLines[m.ix]
      For jx=m.ix+1 To lnLines
        If Atc(m.tcSearchText,arrLines[m.jx]) > 0
          ? m.tcSearchText+" found at line#", m.jx
          ? arrLines[m.jx]
          *perform some calculations
          Exit
        Endif
      Endfor
      Exit
    Endif
  Endfor

Function Search2(tcFile, tcJoint, tcSearchText)
  * Memowidth dependant - a line would be accepted 1024 at max in length
  Set Memowidth To 1024
  Local lcContent, lnStartLine, lnSearchLine
  lcContent = Filetostr(m.tcFile)
  lnStartLine = Atcline(m.tcJoint, m.lcContent)
  If m.lnStartLine<>0 &&found joint line
    ? m.tcJoint +"found on line#",m.lnStartLine
    ? Mline(m.lcContent,m.lnStartLine)
    lnSearchLine = Atcline(m.tcSearchText,Substr(m.lcContent,_Mline))
    If m.lnSearchLine > 0
      ? m.tcSearchText+" found at line#", m.lnStartLine + m.lnSearchLine - 1
      ? Mline(m.lcContent, m.lnStartLine + m.lnSearchLine - 1)
      *perform some calculations
    Endif
  Endif
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