Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP versus C++
Message
From
27/10/2003 09:24:01
 
 
To
27/10/2003 08:42:39
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00842594
Message ID:
00842912
Views:
25
>[snip}
>>Here's my very first attempt:
>>
local lcAll, lnFound, ln
>>*
>>create cursor c_urls ( url c(100), thetime t )
>>*
>>t       = seconds()
>>lcAll   = filetostr( 'index.dat' )
>>lnFound = occurs( 'http://', lcAll )
>>*
>>for ln = 1 to lnFound
>>   *
>>   lcURL = substr( lcAll, at( 'http://', lcAll, ln ), 100 )
>>   lnNIL = at( chr(0), lcURL )
>>   *
>>   if lnNIL > 0
>>      lcURL = left( lcURL, lnNIL - 1 )
>>   endif
>>   *
>>   insert into c_urls values ( lcURL, datetime() )
>>   *
>>   wait wind str( ln ) nowait
>>   *
>>   if inkey() = 113    && character q from quit
>>      exit
>>   endif
>>next
>[snip}
>
>Peter,
>
>I think at( 'http://', lcAll, ln ) is wasting a lot of time
>I guess RegExp would perform a lot faster since you would be using C++ routines
>
>
>*---------------------------------------------------------------------------
>function do_it()
>
>	=Peter()
>
>endfunc
>*---------------------------------------------------------------------------
>function Peter()
>
>	local i, RegExp, Match, lcAll
>	
>	lcAll= 'http://aa.bb.cc' + chr(0) + 'junk http://xx.bb.cc otherjunk' + chr(0)
>	
>	RegExp = CreateObject('VBScript.RegExp')
>	RegExp.Global = TRUE
>        RegExp.IgnoreCase = TRUE
>	RegExp.Pattern = 'http://[^\000 ]+'
>
>	Match = RegExp.Execute(lcAll)
>	
>	for i = 0 to Match.Count - 1
>		? Match.Item[i].Value
>	endfor
>
>endfunc
>*---------------------------------------------------------------------------
>
Wow! That was a blazingly fast 5 seconds only, for all 28,000 urls! What I don't fully understand is your note that it's C++. Isn't it VB?


>Also, I would work with ON ESCAPE instead of INKEY()

No problem with me, although 30,000 times INKEY() took only 0.05 seconds.


>This is only meant as a starting point
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