Find/Select
David Thompson
dthmpsn1 at uiuc.edu
Mon Apr 28 09:41:46 PDT 2008
I think Jay Schille's method was much better than
the one you are quoting, but to answer your
question, an execute command compiles and runs a
procedure that is created on the fly. Let's say
that info("fieldname") returned the word
Address
because the Address field was the active field at
the time. That would put that word into the
fieldname variable. In that case the formula
"Select «"+fieldname+"»=clipboard()"
would produce this text
Select «Address»=clipboard()
The execute command would then treat that text as
a one line procedure. It would compile it, and
run it. The formula was using the + operator as a
concatenation operator. Three strings of text
were being concatenated to produce one string of
text. The first string was "Select «". The second
was the contents of the fieldname variable, which
in this example would be the word "Address" and
the third was "»=clipboard". When all three are
put together, you get the same result as you
would have if you had written "Select
«Address»=clipboard()" as your formula. The
advantage being that you didn't need to know in
advance that the Address field would be the
active field.
Jay Schille's method takes advantage of the fact
that a pair of empty chevrons can be used to
stand for the contents of the active field. It
also uses a local variable, rather than the
clipboard to hold the value you want to use for
comparison. It's much nicer if the user doesn't
have to worry about the contents of the clipboard
being invisibly changed by some procedure. Even
if you will be the only user, it's nice not to
have to worry about that.
Dave
>Would you mind explaining the expression «+fieldname+».
>It's the + signs surroundng the variable name I'm curious about?
>
>________________________________________________________________
>
>On Apr 27, 2008, at 4:14 PM, Jeremy Tice wrote:
>
>>>
>>You're trying to select records where the
>>contents of the variable equals the clipboard,
>>not what the contents of the field whose name
>>matches the contents of the variable. I'd do
>>what you're trying to do with an execute
>>command, like so:
>>
>>global fieldname
>>fieldname=info("fieldname")
>>copy
>>execute "Select «"+fieldname+"»=clipboard()"
>>
>>or, to save a few steps:
>>
>>copy
>>execute "Select «"+info("fieldname")+"»=clipboard()"
More information about the Qna
mailing list