Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining whether a control exists.
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00453834
Message ID:
00454507
Views:
32
>Nadya,
>
>Try this one and see which one is faster.
>
>
>LOCAL i, lnSec
>lnSec=seconds()
>
>for i=1 to 100000
>   if type('oJC.Name')='C'
>   endif
>next
>
>?seconds()-lnSec
>lnSec=seconds()
>
>for i=1 to 100000
>  if vartype(oJC.Name)='C'
>  endif
>next
>?seconds()-lnSec
>
>
>
>BTW, Make sure that oJC does not exist. So how much faster is VarType() now?
>Speed isn't everything you see .,,

Jim,

I'm not arguing about the approach. I'm just telling, that if you want to check Object existence (which is not the part of another object), you can use vartype and it would be faster.

In one of my colleague code I noticed something like:
scan for !Posted
* bunch of code
if type('oPost')<>'O'
oPost=createobject('Post')
endif
* etc.
endscan

Obviously vartype would be faster in this case, though speed benefit is about 0.5 sec. for 10000 records.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform