Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting field presence in dbf
Message
De
28/07/2007 11:54:43
 
 
À
28/07/2007 08:45:02
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Database:
Visual FoxPro
Divers
Thread ID:
01244177
Message ID:
01244368
Vues:
29
Mike,

>It all adds up. Look at it this way: If you opt for all the slowest techniques, your app will work, but it will be sluggish. If you opt for only the fastest techniques your app will be fast.
>
>If you eliminate the slow parts - as some people interpret it - just the biggest most noticeably slow parts, does that mean the app is really fast or barely fast enough?
>
>Since a UDF is slower than a few lines of code, I try to offset the UDF overhead by giving it faster internals. If I can use a single expression and inject it in, I can have the speed with the immediate comprehensiblity of a UDF with the ability to change the UDF and enhance the entire system in one go.
>
>Without a UDF only someone familiar with TYPE knows what this means:
>
>IF NOT TYPE("cAlias.cField")="U"
>
>With a UDF everybody can read this:
>
>IF IsThereAFieldCalled("cAlias.cField")
>
>and when it's learned that FIELD is faster than TYPE just change IsThereAFieldCalled() and you're done. :)

if you are really worried about overhead, at the cost of being more brittle by needing a common .H
create cursor somealias (somefield c(10))
LOCAL lnStop
lnStop = 10000000
a=seconds()
for x = 1 to m.lnStop
  y= !field("somefield","somealias")==""
endfor x
?seconds()-m.a

a=seconds()
for x = 1 to m.lnStop
  y=myudf("somefield","somealias")
endfor x
?seconds()-m.a

a=seconds()
#define IsThereAFieldCalled !SPace(0)==Field
*-- Space may be a tad slower than "" or '', 
*-- but removing the string marker makes it less brittle  
*-- in case of string-building for eval-situations
for x = 1 to m.lnStop
  y=IsThereAFieldCalled("somefield","somealias")
endfor x
?seconds()-m.a

function myudf
lparameters m.tcField, m.tcAlias
return !field("somefield","somealias")==""
regards

thomas
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform