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
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