8

The LA Fox Developer Newsletter
February 1996
LOOKUP() (Con't from page 7)
seconds. This may not seem like a lot of time, but what
if you put 20 lookup command calls on a report. Using
the UDF would start to slow Foxpro down. Using the
command wouldn’t.

Lookup() is a powerful command that can be used in
screens, reports and even validation. To use as a valida-
tion command, just check for EMPTYO. If it’s not empty,
the search key (or entered value) is valid, otherwise, the
Lookup command will return an empty value and you can
then indicate to the user that the entered value is was an
invalid entry. Also, because the LookupO command
returns the same data type as the requested field, you
will never get a data type mismatch error when using this
command.

Some final tips to remember when using LookupO:
1.
Always use fully qualified field names (alias.fieldname)
2.
Always use the fourth parameter (Tag Name)
3.
You can only return one field at a time using lookup, but you
can call Lookup multiple times.
4.
Lookup is fast... very fast.
5.
Lookup doesn’t depend on relationships being set.
[Michael Meer is Vice President of Microcomputer
Engineering Services, LLC, a company that specializes
in highly-customized FoxPro applications and mission-
critical systems, and a certified Visual FoxPro trainer!
instructor for MicroEndeavors, Inc.]

Simple Stuff (Con’t from page 6)
you would use CDOWO, DAYQ and CMONTHO
? CDOW({26106195}),str(DAY((26106195}),2)+’th’,;
CMONTH((26/06/95})

Note - The {} surrounding a date are the equivalent of the
or” " delimiters which define character data. Separat-
ing the fields with commas leaves a space between
each. Using ‘+‘ there are no spaces but data must be of
Character type.

To list all transactions in a field called trans_dat in 1995
you would use the YEAR() function

list for YEAR(trans_dat) = 1995 [fields <field list>]

To list all bills still not paid three months after being sent
out you would use the GOMONTHO function
list for dateQ> gomonth(trans_dat,3)

As with numeric fields, dates can’t be mixed as is’ with

character data if ‘+‘ is used to join fields.
? ‘Your letter dated ‘+ trans_dat

will generate the error

‘operator/operand type mismatch’.

The date needs to be a character string. Use -:

? ‘Your letter dated ‘+ dtoc(rec_on)

And for use in compound indexes you need the DTOSO
function, which changes a date into a yyyymmdd string.
Index on cust_code + dtos(ord_date)
list field cust_code,ord_date

will produce a list ordered by customer with each cus-
tomers’ orders listed in date order.

Well, that’s a start. I’ve avoided jargon as much as
possible, and hope the level is what the originator of that
thread thought was needed. Really the answer to which
data type to use (when there is a choice) depends on
how the data is to be used. You should use the data type
that takes the least amount of coding to produce the
required results.


Out and About (Con't from page 5)
search, go left by Laguna Canyon Road. They will meet
in Building 1, in the back. Use the employee entrance.
Since they have other business going on, do not arrive
before 6:15 pm. For those making presentations, there
will be a projection tablet available with 640 x 480 resolu-
tion only.

TechEd, sponsored by Microsoft, will be April 15-19,
1996, just in time to conflict with DB-Expo (in San Fran-
cisco). Cost of the event will be $1195, if registration is
received by March 1, $1395 after. So start saving yaw
pennies. For info, call 800/545-8240. The last notice I
received stated that all information at the conference
be delivered at an advanced or technical level.

LA Fox Board Meeting this month. Any current/paid
up member of the group is welcome to attend.
Details will be announced at the meeting.
Page 8

8