Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP versus C++
Message
From
27/10/2003 11:40:54
 
 
To
27/10/2003 10:01:38
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00842594
Message ID:
00843016
Views:
24
>Hi Peter,
>
>try this,
>
>create cursor c_urls ( url c(100), thetime t DEFAULT DATETIME())
>
>PRIVATE lcAll, ln ,aUrl
>
>lcAll   = filetostr( 'index.dat' )
>
>* next line is for test
>*lcAll='AAhttp://1'+CHR(0)+'fsdfsdSDFFSDFSDFfhttp://2'+CHR(0)+'sdsdfBFGHDGHGHDGHsdf'
>*FOR K=1 TO 5
>*lcAll=m.lcAll+m.lcAll
>* NEXT
>*? LEN(lcAll)
>** END
>SET ESCAPE ON
>t       = seconds()
>for ln = 2 to ALINES(aUrl, SUBSTR(m.lcAll, AT('http://',m.lcAll)),'http://')
>   STORE AT(CHR(0),aUrl[m.ln]) TO lnNIL
>   if m.lnNIL > 1
>	   insert into c_urls values ( "http://"+LEFT(aUrl[m.ln],m.lnNIL-1), datetime() )
>   ENDIF
>next
>? ln -1, seconds() - t
>
Wow! This code is almost as fast as the RegExp algorithm of Gregory Adam (Re: VFP versus C++ Thread #842594 Message #842893).
They are both under 5 seconds on my machine and the major part of those seconds is used for the FOR/NEXT, which is essentially the same for both.

The interesting thing about your algorithm is that it's pure VFP code. It suggests that it's not only a matter of choosing the right toolbox, but also of choosing the right tools from the toolbox. And obviously VFP has at least one feature on board that does the job we're investigating perhaps (almost) as quick as C++.

For me personally your use of ALINES() is interesting, since I actually use it in the application (VFP versus C++ Thread #842594 Message #842594) in several ways. Basically, what I do is:
do while not feof( lnHR )
   lcC = fgets( lnHR )
   lnFieldsFound = alines( laField, lcC + chr(9), chr(9) )
   for ln = 1 to lnFieldsFound
      *  manipulate laField[ ln ]
   next 
enddo
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform