Tutorial:
Creating A FoxPro Application
Dr. Thomas E. Hicks
Computer Science Department
Trinity University
Download and decompress the following FoxPro Database Files into directory C:\Temp\RestaurantApp
Restaurant Application.
zip
1] The contents of the initial folder should be the Rest.dbf, Rest.cdx, and
Rest.fpt.(See Below!)
2] In order to easily find the wizards that we are going to use on any computer, I recommend placing at least the four screen wizard file in your directory.
3] In order to keep from having dozens of files at the root level, it is best to organize the various files for an application. Some of them will have to be kept in the root directory, but others we shall organize by topic. For example, we shall place all of our images in the BitMaps directory. We shall place all of our forms in the Forms directory. We shall place all of our Reports in the Reports directory. We shall place all of our database tables and indexes in the Data directory. We shall place all of our program code in the Programs directory.
Create all of the directories that you see below. This is a very simple database
application with no relationships and only a single file. For an application as
simple at this, we shall not yet use the Help, Include, Libs, Menu, or Other
directories. See Below.
4] I am including several of the bitmap images that I use for applications in the file below. Extract them and add them to the BitMaps folder. (See Below!)
5] Move the three rest files into the Data folder. (See Below!)
6] This should leave the folowing files/directories at the root level. (See
Below!)
2] Using the mouse, hold down the File Menu and select New (See Below!)
2] Using the mouse, select the Project Radio button. Using the mouse, push the
New File button. (See Below!)
3] If you have set the default properly, the RestaurantApp folder should be in
the Save In bar at the top; Enter a project name of Rest. Using the mouse,
select/push the Save button.
4] The project is now created. (See Below!)
5] This new project should have added files Rest.PJT and Rest.pjx to the root of the RestaurantApp folder. Check it out! (See Below!)
2] Using the mouse, select/push the New Database button. (See Below!)
3] Enter Rest in the Enter Database dialog box. Using the mouse, select/push the
Save button. (See Below!)
4] We now want to add all of our database tables to the database. Using the
mouse, select/push the Add Table button.(See Below!)
5] Go to the Data folder and select each of your tables; only one in this
application. (See Below!)
6] You database now has the Rest Table associated with it! (See Below!) You may
also create new tables with the New Table button. Tables inside the database are
permitted to have much longer field names. Try it!
7] The application provides easy point and click access to all databases, all
tables, and all fields in the tables.
8] The view below shows the Rest table expanded in the Data tab view. Note that
you can modify the table structure or browse the table from this view. (See
Below!)
9] Note that this has added files Rest.DCT and Rest.DCX to the root of your application folder. (See Below!)
2] Using the mouse, select/push the New Form button. (See Below!)
3] It is not the purpose of this tutorial to teach form or report design. Check
one of my other tutorials. Create the following form.
Put your name at the menu
bar in place of mine. Save it as Rest in the Forms folder/directory. We shall
not use all of the buttons yet! (See Below!)
Special Rest Form Settings and Events
4] Your SelectCombo shall have the following 5 options:
5] Your OrderCombo shall have the following 2 options:
Special Search Form Settings and Events
2] Your Search By choices are to have the following 2 options:
3] Your Group To Search - Select choices are to have the following 5 options:

Special Undelete Form Settings and Events
1] Create a full report that professionally displays all of the information of the filtered restaruants with page numbers, dates, and captions. Put a divider line between each record. Call the report FullReport. Store the Reports in the Report folder.
2] Create a Name & Phone report that professionally displays the name and phone of the filtered restaruants with page numbers & dates. Yoiu may put the captions at the top of the columns if you like. Call the report NamePhone.
Extra credit <1> pt If you get the filter information on the report title as well.
1] Create a mailing label that professionally displays the Name on line 1 of a label. Display the Address on line 2. Display the City, State, and Zip on line 3 of the label. Call the label Mail.
1] Your application should now have the following forms, reports, and labels. (See Below!)

3] Using the mouse, right click on main and select Set Main. You may also hold down the project menu and select Set Main. (See Below!)

4] Note that it is now bold. This shall be the program that is run when the executable is built. You must do this in order to create executables. (See Below!)

2] Note that you have to path to the code.prg file that contains all of the
button code. You will also have to path to the database table and the
forms. (See Below!)
2] The Code to associate with button Previous is found below:
3] The Code to associate with button Top is found below:
4] The Code to associate with button Bottom is found below:
5] The Code to associate with button Add is found below:
6] The Code to associate with button Delete is found below:
7] The Code to associate with button Exit is found below:
8] The Code to associate with procedure browse is found below:
9] The Code to associate with button Delete is found below:
10] The Code to associate with button Cancel on the Undelete form is found below:
11] The Code to associate with button Undelete on the Undelete form is found below:
12] The Code to associate with button Search is found below:
13] The Code to associate with button cancel on the Search form is found below:
14] The Code to associate with button Search Now on the Search form is found below:
15] The Code to associate with button SetSearchExample on the Search form is found below:
16] The Code to associate with the Select Combo is found below: In order to more
carefully identify my reports, I add a report subtitle to each report for
clarification. This is most easily done when the filter is set! I save the last
filter and last filter number for restoration purposes. It enables me to restore
the environment in situations where I might have just run a report for Texas
restaurants.
Continuation of SetFilterNo. Note that we should not allow the user to set a
filter that provides zero records.
17] The Code to associate with the Order Combo is found below: I save the last
order and last order number for restoration purposes. It enables me to restore
the environment in situations where I might have just run a report for Texas
restaurants in order by name.
18] The Code to associate with button Print is found below:
19] The Code to associate with the Cancel button on the Print form is found below:
20] The Code to associate with the Print button on the Print form is found below:
Unfortunately there is an error in the distribution of the Visual Studio 6 that
prevents the rest of the record option from working.
Continuation Of AcceptPrint
Messages for these buttons shall be:
1] Your RestarurantApp folder probably looks something like the following:

2] The code in the previous Exit module did not really exit foxpro. It allowed you to get an idea of what your application was going to look like. It is now time to correct the Exit module

3] Using the mouse, select the Code tab of your project. Using the mouse, select the main program. Using the mouse select/push the Build button. (See Below!)

4] Using the mouse, select the Build Executable radio button. Using the mouse select/push the OK button. (See Below!)

5] Name the executable Rest.exe. Using the mouse select/push the Save button. (See Below!)

6] The executable is now complete. You may execute it by double-clicking on it. Try it! (See Below!)


1] Using the mouse, hold down the Tools menu bar ==> Select Wiards ==> Select Setup. (See Below!)

2] Push the file access button to select the distribution files. Once more, I recommend placing them in the Program Files directory. (See Below!)

3] As you perhaps noticed on the screen capture above, I have placed my distribution files in C:\Test-RestaurantApp folder. Navigate to the proper folder, and select/push the Select button. (See Below!)

4] Using the mouse, select/push the Next button. (See Below!)

5] Using the mouse, check Visual FoxPro runtime components. Using the mouse, select/push the Next button. (See Below!)

6] You may place your distribution disk in any existing folder. I have prepared, in advance, a folder C:\RestApp-Disks for this purpose. Navigate to the desired folder. Using the mouse, select/push the Select button. (See Below!)

7] Using the mouse, select/push the Next button. (See Below!)

8] The Setup dialog box caption is vital; select something appropriate. Notice how many times you see this string during the install process. Copyright is optional as is appropriate. You can select a program to execute upon completion. Using the mouse, select/push the Next button. (See Below!)

9] Using the mouse, select/push the Finish button. (See Below!)

10] It starts to work! Does not take long.

11] It will require 3 floppy disks to store those run-time DLL's necessary to run this foxpro application on a system that has neither FoxPro nor another FoxPro application.

12] Created for you in the desired location is a folder called DISK144. You may copy DISK1 to the root of floppy disk #1 and DISK2 to the root of floppy disk #2 and DISK3 to the root of floppy disk #3; this will enable you to install from floppy disks.


2] Note the Setup Dialog Caption. Using the mouse select/push the Continue button.

3] It pulls info from previous windows install.

4] Using the mouse select/push the OK button.

5] Working!

6] It would have been so much less trouble for the user if I had created the installation disks from the Program Files directory. A knowledgeable user will want to change the location. Using the mouse select/push the Change Folder button.

7] Select Program Files directory and give the folder a decent title. Using the mouse select/push the OK button.

8] Using the mouse select/push the Yes button.

9] Using the mouse select/push the OK button.

10] Working!

11] Using the mouse select/push the Application Installation button.

12] Working!

13] Still Working!

14] Using the mouse select/push the OK button.

15] The application now exists in folder C:\Program Files\Restaurant. You may launch it by double-clicking on it. You may create a short cut to it and place it in the start menu or on the desktop. Try it!

