Reply-To: erik.wachtmeester@bighole.iaf.nl
Ron Tuynman wrote in a message to Erik Wachtmeester:
RT> //---Detecting:
RT> aRay := DBSTRUCT ( "NAME.DBF" )
RT> log := .f.
RT> FOR d = 1 to LEN aRay
RT> IF "ADRESS" $ UPPER( aRay[ d ][ 1 ] )
RT> //---Log becomes true if a field named ADRESS exists
RT> log := .t.
RT> ENDIF
RT> NEXT
EW> Instead of the for/next loop I would use something like:
EW> log := ( ascan( aRay, { |x| x[1] = 'ADDRESS' } ) # 0 )
RT> ...Yep, but it's doesn't show as much what I'm actually doing as
RT> FOR...NEXT. I like to keep it as simple as possible. Especially when
RT> I'm explaining thing to someone else...
I agree on that one, but I simply love the speed and flexibility of code
blocks
in Clipper, and I tend to use them whenever possible. If you're not using
ode
blocks, you're not using Clipper to the full... ;-)
RT> And furthermore: I think your code wouldn't work..;-) Oh, sorry it
RT> would! Me myself I always use the '==' for comparison, not the soft
RT> '='. With == it would never have found ADRESS1 as a fieldname...
With strings '=' is a good replacement for e.g. '/^' in SED, AWK, Perl, etc.
It
forces your program to check only at the beginning of the other string, while
'$' searches the whole string.
If you know the string to compare with must start with 'ADDRESS', it's just
natural to me to use '=' instead of '$'.
Regards,
Erik
---
---------------
* Origin: May it be on this earth? (2:283/7.2)
|