Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
I'm loosing a VFP - VB battle
Message
From
08/03/2000 20:09:57
 
 
To
08/03/2000 19:54:16
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00342582
Message ID:
00343527
Views:
41
>I was able to speed up the results to .05 seconds by switching from using strtofile to using FREAD, etc. The other problem with the algorithm is that it, well, doesn't work. It misses some entries.
>
>So, if nothing else the VB's guys beat us to a solution that is correct.

What does it miss?

This "Andy '86 and Martha '87 Shaindlin"?

I modified it to give year output like the example:

* relative timings
*!*     Albert1 -        0.109
*!*     Albert1 -        0.125
*!*     Albert1 -        0.109
*!*     Albert1 -        0.109
*!*     Albert1 -        0.109
*!*     Albert1 -        0.109
*!*     Albert1 -        0.110
*!*     Albert1 -        0.110
*!*     Albert1 -        0.109
*!*     Albert1 -        0.109
*!*     Nancy -        0.297
*!*     Nancy -        0.281
*!*     Nancy -        0.297
*!*     Nancy -        0.296
*!*     Nancy -        0.297
*!*     Nancy -        0.328
*!*     Nancy -        0.281
*!*     Nancy -        0.282
*!*     Nancy -        0.296
*!*     Nancy -        0.297
*!*     Albert2 -        0.125
*!*     Albert2 -        0.110
*!*     Albert2 -        0.093
*!*     Albert2 -        0.094
*!*     Albert2 -        0.094
*!*     Albert2 -        0.093
*!*     Albert2 -        0.109
*!*     Albert2 -        0.094
*!*     Albert2 -        0.109
*!*     Albert2 -        0.094
set safety off
local vfCRLF, lc3CRs
vfCRLF = chr(13) + chr(10)
lc3CRs = chr(13) + chr(13) + chr(13)
Local lcSafety, lnSeconds, lcBrownAlums, lnTagStart, ;
     lcAlum, lnFirstQuote, lcURL, lnYearQuote, ;
     lcName, lcYear, lcSortYear, lcOutput
local array laTags[1]
local array laQuotes[1]
*!*     Set COVERAGE TO nf.txt
lnSeconds = SECONDS()
lcBrownAlums = FILETOSTR("BrownAlpha.html")
lcBrownAlums = chrtran(lcBrownAlums, chr(13), "")
lcBrownAlums = chrtran(lcBrownAlums, chr(10), "")
lnTagStart = AT("<UL>", lcBrownAlums)
lcBrownAlums = SUBSTR(lcBrownAlums, lnTagStart )
lcBrownAlums = strtran(lcBrownAlums, "<A HREF=", chr(13) + "<A HREF=")
lcBrownAlums = strtran(lcBrownAlums, "<AHREF=", chr(13) + "<A HREF=")
lcBrownAlums = strtran(lcBrownAlums, "</A>", "</A>" + chr(13))
*!* It's much faster to build the string, then write the file
*!*     Strtofile("<ALUMLIST>" + vfCRLF, "brown.xml")
lcFileStr = "<ALUMLIST>" + vfCRLF
for i = 1 to alines(laTags, lcBrownAlums)
     If laTags[i] = "<A HREF="
          laTags[i] = chrtran(laTags[i], '"><', lc3CRs)
          =alines(laQuotes, laTags[i])
          lcURL = laQuotes[3]
          lcName = laQuotes[4]
*!*               laQuotes[4] = chrtran(laQuotes[4], "'", chr(13))
*!*               =alines(laNameYear, laQuotes[4])
*!*               If alines(laNameYear, laQuotes[4]) > 1
*!*                    lcYear = "'" + laNameYear[2]
*!*                    lcSortYear = "19" + left(laNameYear[2], 2)
*!*               Else
*!*                    lcYear = ''
*!*                    lcSortYear = ''
*!*               Endif
          lnYearQuote = AT("'", laQuotes[4])
          If lnYearQuote > 0
               lcName = left(laQuotes[4], lnYearQuote - 1)
               lcYear = SUBSTR(laQuotes[4], lnYearQuote)
               lcSortYear = "19" + SUBSTR(lcYear, 2, 2)
          Else
               lcName = laQuotes[4]
               lcYear = ''
               lcSortYear = ''
          Endif
          lcName = rtrim(lcName)
          lcFileStr = lcFileStr + "  <ALUM>" + vfCRLF + ;
               "    <NAME>" + lcName + "</NAME>" + vfCRLF + ;
               "    <SHOWYEAR>" + lcYear + "</SHOWYEAR>" + vfCRLF + ;
               "    <SORTYEAR>" + lcSortYear + "</SORTYEAR>" + vfCRLF + ;
               "    <URL>" + lcURL + "</URL>" + vfCRLF + ;
               "  </ALUM>" + vfCRLF
     Endif
Endfor
Strtofile(lcFileStr+"</ALUMLIST>", "browna.xml")
lnSeconds = SECONDS() - lnSeconds
=strtofile( "Albert2 - " + str(lnSeconds, 12, 3) + vfCRLF, "results.txt", .t. )
Release ALL
Clear ALL
*!*     Set COVERAGE TO
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform