home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
FOXPRO
/
TABLES
/
TBLSRC
/
TABLE.DOC
next >
Wrap
Text File
|
1992-11-13
|
5KB
|
126 lines
Field Table Routines
by
Mark D. Miller
71054,3103
The .zip file you downloaded should contain the following files:
TBLDEMO.EXE Executable showing the routines in action.
TBLDEMO.PRG Demo program source.
TBLSAMP.DBF Sample database.
TBLSAMP.FDX Sample index.
TABLE.LIB The linkable library of routines.
TABLE.HDR The function and procedure declarations.
TABLE.DOC This file.
-AND-
SEX.TBL Example table files.
EEOC.TBL
STATE.TBL
PROGRAM.TBL
If you did not receive all of these files or if any of the files
were corrupted, please leave me a message in the FORCE forum on
CIS.
PURPOSE
The purpose of this library is to provide the developer with a
simple but elegant method of allowing the end user to vary the
input into various multiple choice fields while still maintaining
control over what actually is input.
The table routines are self-validating, meaning that they will not
allow an entry into a field that has not been defined in the table.
WHAT ARE TABLES?
The table itself is simple to construct with any ASCII text editor.
The table is simply a list of ASCII strings describing the table
contents, with the first line in the table being reserved as a
HEADER line to determine the TYPE of the table.
Tables come in two flavors: RELATIVE and INDEXED. Both are
described below.
RELATIVE INDEXED
1 Tools 2 Nationalities
Anvil E-English
Screwdriver (Standard) B-British
Screwdriver (Phillips) C-Chinese
Wrench (Box End) J-Japenese
Wrench (Open End) G-German
Wrench (Combination) H-Hungarian
Note the differences between the two tables. A RELATIVE table
simply assigns each line a number, such that Anvil becomes number
1 in your field and Wrench (Open End) becomes number 5. An INDEXED
table, on the other hand uses the KEY (that part of the string
before the hyphen) as the field value and the INDEX into the table.
Note that the KEY can be from 1 to 4 characters long and a table
can have keys of varying lengths as long as the GET field on the
screen is as long as the longest key in the table.
Note also that order does not matter in the tables but you may want
to place the most likely used entries near the top of the table.
USING THE TABLE LIBRARY
Using the table routines in your programs is straightforward.
Simply follow the example given in the TBLDEMO.PRG program. Listed
below is the parameters for the TABLE() and VERIFYTABLE()
functions.
FUNCTION UINT Table
PARAMETERS CONST CHAR( 8 ) Name,;
CONST UINT TableRow,;
CONST UINT TableCol,;
CONST UINT Length,;
CHAR( 4 ) PKey
FUNCTION LOGICAL VerifyTable
PARAMETERS CONST CHAR( 8 ) Name,;
CONST UINT TableRow,;
CONST UINT TableCol,;
CONST UINT Length,;
CHAR( 4 ) PKey
CHAR( 8 ) Name
This is the DOS file name of the table file to use.
Table files must be in the same directory as the program
and must have the extension ".tbl". The name MUST BE IN
ALL CAPS.
UINT TableRow
UINT TableCol
UINT Length
These three parameters tell the library where to display
the table values and how long the longest table value
will be. The portion of the line starting at
TableRow,TableCol and extending for Length characters
will be cleared whenever the GET field is accessed.
CHAR( 4 ) PKey
This is the name of the GET field that this table is
attached to. This is so the library can read what the
current value in the GET field is.
COMPILING AND LINKING
Follow the guidelines in TBLDEMO.PRG to attach the table routines
to your GET fields, compile your programs as you would normally and
link with the table library as follows:
LINK TBLDEMO,,,FORCE+TABLE;
Note this example is for MSLINK and assumes all modules are in the
current directory or on your search path.
CONCLUSION
Comments and suggestions are welcome. If you find these routines
useful, I would appreciate your support by sending a $5.00 check
to:
Mark D. Miller
612 Fairview Blvd. Apt. RNW
Rockford, IL 61107