Dec 122017
Browse builder for Foxpro 2.5. | |||
---|---|---|---|
File Name | File Size | Zip Size | Zip Type |
BLDBROW.DOC | 7364 | 2680 | deflated |
BLDBROW.FXP | 696 | 696 | stored |
ORDERFRM.DOC | 1500 | 482 | deflated |
Download File BLDBROW.ZIP Here
Contents of the BLDBROW.DOC file
BUILDING A BROWSE SCREEN
Fred Wampler
Before FoxPro, I rarely used the browse command in a
programming environment--now I use it heavily. If you are
taking advantage of one of FoxPro's most powerful
features, you are using it heavily too. It does not take
long to discover that a lot of typing goes into a browse
command. Usually I will want to rename the field header,
limit the field length, include validation, rearrange
field display order or leave some fields out. To help
reduce the typing, I wrote and use BLDBROW to write a
browse fragment taken from the database structure. The
resulting code is written to the file BLDBROW.TXT then
"read in" (inserted) into my program for further
modification.
Example
LISTING 2 shows the structure of a sample database. The
program BLDBROW, LISTING 1, takes information from that
structure and builds the code fragment displayed in
LISTING 3. LISTING 4 shows how I modified the code to
suit my purposes. Obviously, much typing was eliminated!
Notice in LISTING 4 that 3 fields, used internally by the
program, were removed from the browse window. As an
aside, I make heavy use of computer generated IDs. I use
George Goley's program, ncompress, to transform the
numbers into a manageable 4 characters (Data Based Advisor
3/1988.) For example, a user would select a customer or
vendor from a screen displaying name, address, phone, etc.
Upon selection, the computer would tie all references to
that customer by using the unique computer-generated ID
located in that customer's record. Notice, also, that many
field headers were renamed. Although no validation or
other modifications were made, it would be easy to do so.
The comments about record structure at the beginning of
the listing can be removed, if desired, once the code is
modified to suit your requirements.
FoxPro Macros
If you are not making full use of the FoxPro editor, you
may be losing out in terms of speed and efficiency of your
programming output. FoxPro macros allow you to configure
the editor to suit your preferences. For example, I call
BLDBROW from inside the program I am editing by pressing
SHIFT-F4 (See LISTING 5). The browse fragment is written
to the file BLDBROW.TXT and then automatically inserted at
the cursor of the program I am writing. This is fast and
easy and very efficient. Notice, in LISTING 5, I define
F6 to call the expression builder. Code from the
expression builder is inserted, at the cursor, into the
program I am writing or editing. SHIFT-F2, callable
during the edit session, opens a window displaying the
database structure of interest. SHIFT-F3 inserts a
program header with correct date and time into the program
I am editing (See LISTING 1.) Other programming features
let me duplicate the line, duplicate the character above,
call the filer and many others. Efficient use of the
FoxPro editor particularly using macros would make good
topics for a series of articles to XXXXXX! Maybe someone
who is interested could submit his/her favorites.
LISTING 1.
LISTING 2. Database Structure
Structure for database: C:\WAYNE\ADDITV.DBF
Number of data records: 146
Date of last update : 08/29/90
Field Field Name Type Width Dec
1 TRADENAME Character 25
2 ADD_ID Character 4
3 CHEM_ID Character 4
4 PROD_ID Character 4
5 ADD_TYPE Character 25
6 CHEM_FAM Character 25
7 SOL_PRM Numeric 5 1
8 MW Numeric 5
9 MELT_RANGE Character 10
10 WAVE_MAX Character 10
11 EXT_COEFF Character 10
12 SPGR Numeric 5 3
13 APPEAR Character 40
14 PRICE Character 10
15 PR_DATE Date 8
16 NOTEBOOK Character 10
17 ACC_NO Character 15
18 COMMENT Character 25
19 COMMT Memo 10
20 PM_NO Character 15
** Total ** 266
LISTING 3. Browse Fragment Produced by BLDBROW
* C:\WAYNE\ADDITV.DBF 10/13/90 07:25:23
* FIELD COUNT: 20
* 1 TRADENAME C25
* 2 ADD_ID C4
* 3 CHEM_ID C4
* 4 PROD_ID C4
* 5 ADD_TYPE C25
* 6 CHEM_FAM C25
* 7 SOL_PRM N
* 8 MW N
* 9 MELT_RANGE C10
* 10 WAVE_MAX C10
* 11 EXT_COEFF C10
* 12 SPGR N
* 13 APPEAR C40
* 14 PRICE C10
* 15 PR_DATE D
* 16 NOTEBOOK C10
* 17 ACC_NO C15
* 18 COMMENT C25
* 19 COMMT M
* 20 PM_NO C15
BROWSE FIELDS ;
TRADENAME:H=[Tradename] ,;
ADD_ID:H=[Add_id] ,;
CHEM_ID:H=[Chem_id] ,;
PROD_ID:H=[Prod_id] ,;
ADD_TYPE:H=[Add_type] ,;
CHEM_FAM:H=[Chem_fam] ,;
SOL_PRM:H=[Sol_prm] ,;
MW:H=[Mw] ,;
MELT_RANGE:H=[Melt_range] ,;
WAVE_MAX:H=[Wave_max] ,;
EXT_COEFF:H=[Ext_coeff] ,;
SPGR:H=[Spgr] ,;
APPEAR:H=[Appear] ,;
PRICE:H=[Price] ,;
PR_DATE:H=[Pr_date] ,;
NOTEBOOK:H=[Notebook] ,;
ACC_NO:H=[Acc_no] ,;
COMMENT:H=[Comment] ,;
COMMT:H=[Commt] ,;
PM_NO:H=[Pm_no]
* WINDOW <> COLOR SCHEME 7 NOAPPEND TITLE [] WIDTH 15
LISTING 4. Modified Browse Fragment
* C:\WAYNE\ADDITV.DBF 10/13/90 07:25:23
* FIELD COUNT: 20
* 1 TRADENAME C25
* 2 ADD_ID C4 REMOVE (internal ID) ncompress
* 3 CHEM_ID C4 REMOVE by George Goley
* 4 PROD_ID C4 REMOVE Data Based Advisor 3/1988
* 5 ADD_TYPE C25
* 6 CHEM_FAM C25
* 7 SOL_PRM N
* 8 MW N
* 9 MELT_RANGE C10
* 10 WAVE_MAX C10
* 11 EXT_COEFF C10
* 12 SPGR N
* 13 APPEAR C40
* 14 PRICE C10
* 15 PR_DATE D
* 16 NOTEBOOK C10
* 17 ACC_NO C15
* 18 COMMENT C25
* 19 COMMT M
* 20 PM_NO C15
BROWSE FIELDS ;
TRADENAME:H=[Trade name] ,;
ADD_TYPE:H=[Additive type] ,;
CHEM_FAM:H=[Chemical family] ,;
SOL_PRM:H=[Solubility parameter] ,;
MW:H=[Molecular weight] ,;
MELT_RANGE:H=[Melt range] ,;
WAVE_MAX:H=[Wave max] ,;
EXT_COEFF:H=[Extinction coeff] ,;
SPGR:H=[Sp gr] ,;
APPEAR:H=[Appearance] ,;
PRICE:H=[Price] ,;
PR_DATE:H=[Price date] ,;
NOTEBOOK:H=[Notebook] ,;
ACC_NO:H=[Acct #] ,;
COMMENT:H=[Remark] ,;
COMMT:H=[Notes] ,;
PM_NO:H=[Pm #] ;
WINDOW COLOR SCHEME 7 NOAPPEND TITLE [] WIDTH 15
LISTING 5. Snap Shot of My Keyboard Macros
System File Edit Macros
Keyboard Macros
F6_GET_EXPR
< Save > F7_COMPILE < New >
F8_GET_WINDOW
< Restore > F9_SAVE_FILE < Clear >
SF4_BLDBROW
SHIFT_F2_STRUCTURE < Clear All >
SHIFT_F3_HEADER
OK
Fred Wampler
Before FoxPro, I rarely used the browse command in a
programming environment--now I use it heavily. If you are
taking advantage of one of FoxPro's most powerful
features, you are using it heavily too. It does not take
long to discover that a lot of typing goes into a browse
command. Usually I will want to rename the field header,
limit the field length, include validation, rearrange
field display order or leave some fields out. To help
reduce the typing, I wrote and use BLDBROW to write a
browse fragment taken from the database structure. The
resulting code is written to the file BLDBROW.TXT then
"read in" (inserted) into my program for further
modification.
Example
LISTING 2 shows the structure of a sample database. The
program BLDBROW, LISTING 1, takes information from that
structure and builds the code fragment displayed in
LISTING 3. LISTING 4 shows how I modified the code to
suit my purposes. Obviously, much typing was eliminated!
Notice in LISTING 4 that 3 fields, used internally by the
program, were removed from the browse window. As an
aside, I make heavy use of computer generated IDs. I use
George Goley's program, ncompress, to transform the
numbers into a manageable 4 characters (Data Based Advisor
3/1988.) For example, a user would select a customer or
vendor from a screen displaying name, address, phone, etc.
Upon selection, the computer would tie all references to
that customer by using the unique computer-generated ID
located in that customer's record. Notice, also, that many
field headers were renamed. Although no validation or
other modifications were made, it would be easy to do so.
The comments about record structure at the beginning of
the listing can be removed, if desired, once the code is
modified to suit your requirements.
FoxPro Macros
If you are not making full use of the FoxPro editor, you
may be losing out in terms of speed and efficiency of your
programming output. FoxPro macros allow you to configure
the editor to suit your preferences. For example, I call
BLDBROW from inside the program I am editing by pressing
SHIFT-F4 (See LISTING 5). The browse fragment is written
to the file BLDBROW.TXT and then automatically inserted at
the cursor of the program I am writing. This is fast and
easy and very efficient. Notice, in LISTING 5, I define
F6 to call the expression builder. Code from the
expression builder is inserted, at the cursor, into the
program I am writing or editing. SHIFT-F2, callable
during the edit session, opens a window displaying the
database structure of interest. SHIFT-F3 inserts a
program header with correct date and time into the program
I am editing (See LISTING 1.) Other programming features
let me duplicate the line, duplicate the character above,
call the filer and many others. Efficient use of the
FoxPro editor particularly using macros would make good
topics for a series of articles to XXXXXX! Maybe someone
who is interested could submit his/her favorites.
LISTING 1.
LISTING 2. Database Structure
Structure for database: C:\WAYNE\ADDITV.DBF
Number of data records: 146
Date of last update : 08/29/90
Field Field Name Type Width Dec
1 TRADENAME Character 25
2 ADD_ID Character 4
3 CHEM_ID Character 4
4 PROD_ID Character 4
5 ADD_TYPE Character 25
6 CHEM_FAM Character 25
7 SOL_PRM Numeric 5 1
8 MW Numeric 5
9 MELT_RANGE Character 10
10 WAVE_MAX Character 10
11 EXT_COEFF Character 10
12 SPGR Numeric 5 3
13 APPEAR Character 40
14 PRICE Character 10
15 PR_DATE Date 8
16 NOTEBOOK Character 10
17 ACC_NO Character 15
18 COMMENT Character 25
19 COMMT Memo 10
20 PM_NO Character 15
** Total ** 266
LISTING 3. Browse Fragment Produced by BLDBROW
* C:\WAYNE\ADDITV.DBF 10/13/90 07:25:23
* FIELD COUNT: 20
* 1 TRADENAME C25
* 2 ADD_ID C4
* 3 CHEM_ID C4
* 4 PROD_ID C4
* 5 ADD_TYPE C25
* 6 CHEM_FAM C25
* 7 SOL_PRM N
* 8 MW N
* 9 MELT_RANGE C10
* 10 WAVE_MAX C10
* 11 EXT_COEFF C10
* 12 SPGR N
* 13 APPEAR C40
* 14 PRICE C10
* 15 PR_DATE D
* 16 NOTEBOOK C10
* 17 ACC_NO C15
* 18 COMMENT C25
* 19 COMMT M
* 20 PM_NO C15
BROWSE FIELDS ;
TRADENAME:H=[Tradename] ,;
ADD_ID:H=[Add_id] ,;
CHEM_ID:H=[Chem_id] ,;
PROD_ID:H=[Prod_id] ,;
ADD_TYPE:H=[Add_type] ,;
CHEM_FAM:H=[Chem_fam] ,;
SOL_PRM:H=[Sol_prm] ,;
MW:H=[Mw] ,;
MELT_RANGE:H=[Melt_range] ,;
WAVE_MAX:H=[Wave_max] ,;
EXT_COEFF:H=[Ext_coeff] ,;
SPGR:H=[Spgr] ,;
APPEAR:H=[Appear] ,;
PRICE:H=[Price] ,;
PR_DATE:H=[Pr_date] ,;
NOTEBOOK:H=[Notebook] ,;
ACC_NO:H=[Acc_no] ,;
COMMENT:H=[Comment] ,;
COMMT:H=[Commt] ,;
PM_NO:H=[Pm_no]
* WINDOW <> COLOR SCHEME 7 NOAPPEND TITLE [] WIDTH 15
LISTING 4. Modified Browse Fragment
* C:\WAYNE\ADDITV.DBF 10/13/90 07:25:23
* FIELD COUNT: 20
* 1 TRADENAME C25
* 2 ADD_ID C4 REMOVE (internal ID) ncompress
* 3 CHEM_ID C4 REMOVE by George Goley
* 4 PROD_ID C4 REMOVE Data Based Advisor 3/1988
* 5 ADD_TYPE C25
* 6 CHEM_FAM C25
* 7 SOL_PRM N
* 8 MW N
* 9 MELT_RANGE C10
* 10 WAVE_MAX C10
* 11 EXT_COEFF C10
* 12 SPGR N
* 13 APPEAR C40
* 14 PRICE C10
* 15 PR_DATE D
* 16 NOTEBOOK C10
* 17 ACC_NO C15
* 18 COMMENT C25
* 19 COMMT M
* 20 PM_NO C15
BROWSE FIELDS ;
TRADENAME:H=[Trade name] ,;
ADD_TYPE:H=[Additive type] ,;
CHEM_FAM:H=[Chemical family] ,;
SOL_PRM:H=[Solubility parameter] ,;
MW:H=[Molecular weight] ,;
MELT_RANGE:H=[Melt range] ,;
WAVE_MAX:H=[Wave max] ,;
EXT_COEFF:H=[Extinction coeff] ,;
SPGR:H=[Sp gr] ,;
APPEAR:H=[Appearance] ,;
PRICE:H=[Price] ,;
PR_DATE:H=[Price date] ,;
NOTEBOOK:H=[Notebook] ,;
ACC_NO:H=[Acct #] ,;
COMMENT:H=[Remark] ,;
COMMT:H=[Notes] ,;
PM_NO:H=[Pm #] ;
WINDOW
LISTING 5. Snap Shot of My Keyboard Macros
System File Edit Macros
Keyboard Macros
F6_GET_EXPR
< Save > F7_COMPILE < New >
F8_GET_WINDOW
< Restore > F9_SAVE_FILE < Clear >
SF4_BLDBROW
SHIFT_F3_HEADER
OK
December 12, 2017
Add comments