Dr.
Thomas E. Hicks
Computer Science
Department
Trinity University
Products1.zip Installing WinZip Tutorial Using WinZip Tutorial
Create a folder, called Products, in the Temp folder of hard drive C; your directory C:\Temp\Products should look like the following:
Structure for table:
C:\TEMP\PRODUCTS\PRODUCTS.DBF
Number of data records:
77
Date of last update:
02/27/98
Memo file block size:
64
Code Page:
1252
Field Field Name Type
Width
Dec
1 PRODUCTID Character
6
2 SUPPLIERID Character
6
3 PRODNAME Character
40
4 ENGNAME Character
50
5 QTYSIZE Character
20
6 UNITPRICE Numeric
8
2
7 UNITCOST Numeric
8
2
8 QTYINSTOCK Numeric
12
3
9 MINQTYTOST Numeric
12
3
10 DISCONTINU Logical
1
11 LASTORDER Date
8
12 INFO
Memo
In order to avoid typing a lot of stuff in the command line each time we wish to start our application, let us design a good Main.PRG (Do It!)
Modify Command Main
Set Default To C:\Temp\Products
<-- establish the default drive/folder
Use Client <-- commented open database Client.DBF
Set Deleted On <-- turn on the deleted filter
Set Bell Off <-- turn off the bell
Set Near On <-- allow searching to find a near match
Set Procedure To Code <-- associate the button code file for the current screen application
Clear <-- clear the console screen
Do Form Products
<-- run the Products screen form

Using the mouse, select the Set As Default button. (Do It!)
Until this configuration is changed, all new screens will
be designed for low resolution 640 x 480 monitors with snap to grid set
to 6 pixels.
Create Screen Products <-- Launches the screen designer to create a screen called Products.SCX.

Using the mouse, hold down the form menu and select QuickForm as illustrated above. A form builder will now emerge. As is the case with the other FoxPro Menus, the Form Control menu may be in the menubar at the top, may be loose on the screen (as illustrated above) or may be closed. If closed, the toolbar may be opened by holding down the View Menu and selecting Forms Control Tool Bar.

Used to add the selected field from the Products database table to the
Selected Fields list used to construct controls for the new form.
Used to add all fields from the Products database table to the Selected
Fields list used to construct controls for the new form.
Used to remove the selected field from the Selected Fields list.
Used to remove all fields from the Selected Fields list.
Let us select all fields. (See Below)

Select the Tab form builder. (See Below)

Select the Embossed Style and Select the OK button. (See Below)

FoxPro has now given its best shot at an automated form
for the Products database table.
Each caption/prompt is a text box control object whose properties may be altered. Let us change the caption of Productid to Product ID #. First use the mouse and select the text box control; when selected, a box will appear around the text box.

Second let us activate the Properties Box by holding down the right mouse button on the object and selecting Properties as demonstrated above. The Properties Box is illustrated below. This step may be omitted when the properties box is already on the desktop.

In order to change the text box control caption :

This
button, from the form controls tool bar, can be used to add a new text
box control to a screen.
In order to make the text box control bold
for a color chart. (See Below)

athomas.Custom colors may be configured as well. (See Below)

You may use your mouse and select multiple text box controls
to change at one time; hold down the shift key to continue selections.

In order to make the text box control unbold

You may use your mouse and select multiple text
box controls to change at one time; hold down the shift key to continue
selections.

You may use your mouse and select multiple text box controls to change at one time; hold down the shift key to continue selections.
This
button, from the form controls tool bar, can be used to add a new edit
box control to a screen.
In order to make the edit box control bold

In order to make the edit box control unbold

In order to change the font background color
I. Put the most important information at the top of the screen.
II. Most screens should contain 1 - 3 columns
III. Avoid wild color combinations.
IV. Avoid too many different size fonts.
V. Try to avoid large gaps on the page.

VI. Align the prompt captions and the edit fields. The captions below need help. Select the left row of captions with the mouse on the screen below. Pull down the Format Menu and Select Align and select Align Right Sides.


The results of the right alignment may be seen below. This will also be done with the left column.

FoxPro also makes it very easy to achieve horizontal alignment in each row. Select the left row of captions with the mouse on the screen below.

Pull down the Format Menu and Select Align and select Align Right Sides.

With proper alignment, our screen now looks like the following:
In order to change the screen title from Form1
The
purpose of the Next button is to move the cursor to the next record. This
button, from the form controls tool bar, can be used to add a new push
button control to a screen. The Next Button should be on the far right-hand
side of the screen.
The code for all buttons shall be added to a file called Code.PRG. Do It!
modify command Code
Procedure Next
<-- Beginning of the Procedure Next
Skip 1
<-- Skip a record - Don't forget to indent!
If EOF() Then
<-- Start of the If Then Else Decision Statement
Goto Top <-- When you hit the End Of File Then Goto the top of the file
EndIf
<-- Start of the If Then Else Decision Statement
_screen.activeform.refresh
<-- Refresh the screen form
Return
<-- Return control to place that called Next
EndProc <-- End of Procedure - Optional Statement

In order to change the Next push button control caption :


Double click on My Computer. Double
click on Temp. Double click on Products.
Double click on Main.PRG <--
To start the Products screen from Windows.

The code for all buttons shall be added to a file called Code.PRG. Do It! Skip a couple of blank lines between your procedures to make them easier to find, edit, etc.
modify command Code
Procedure Previous <-- Beginning of the Procedure Previous
Skip -1 <-- Skip back one record - Don't forget to indent!
If BOF() Then
<-- Start of the If Then Else Decision Statement
Goto Bottom <-- When you hit the Beginning Of File Then Goto the bottom of the file
EndIf <-- Start of the If Then Else Decision Statement
_screen.activeform.refresh
<-- Refresh the screen form
Return <-- Return control to place that called Previous
EndProc
<-- End of Procedure - Optional Statement

The code for all buttons shall be added to a file called Code.PRG. Do It! Skip a couple of blank lines between your procedures to make them easier to find, edit, etc.
modify command Code
Procedure Delete <-- Beginning of the Procedure Delete
Delete <-- Delete the current record - Don't forget to indent!
Do Next
<-- Move the read/write pointer to the next undeleted record
Return <-- Return control to place that called Delete
EndProc <-- End of Procedure - Optional Statement
The code for all buttons shall be added to a file called
Code.PRG. Do It! Skip a couple of blank lines between your procedures to
make them easier to find, edit, etc.
The
purpose of the Add button is to move the cursor to the previous record.
The Add Button may be placed anywhere, that is organize effectively,
the screen.
modify command Code
Procedure Add <-- Beginning of the Procedure Add
Append Blank <-- Append new blank record
at eof - move read/write pointer
to that record
_screen.activeform.refresh
<-- Refresh the screen form
Return <-- Return control to place that called Add
EndProc <-- End of Procedure - Optional Statement
The
purpose of the Exit button is to exit the screen form. The Exit Button
may be placed anywhere, that is organize effectively, the screen.
The code for all buttons shall be added to a file called Code.PRG. Do It! Skip a couple of blank lines between your procedures to make them easier to find, edit, etc.
modify command Code
Procedure Exit <-- Beginning of the Procedure Exit
_screen.activeform.release
<-- Refresh the screen form
Return <-- Return control to place that called Exit
EndProc <-- End of Procedure - Optional Statement