Special Edition Using Visual FoxPro 6
Special Edition Using Visual FoxPro 6
The Visual FoxPro Wizards
- What Are the Wizards?
- Application Wizard and Builder
- Documenting Wizard
- Setup Wizard
- WWW Search Page Wizard
- Web Publishing Wizard
Magic wands and cauldrons of boiling liquid are the images I see when I think of wizards. Bearded men with long flowing robes and pointy hats come to mind. The Visual FoxPro Wizards don't fall into this category, though.
A wizard in Visual FoxPro is an interface that makes the creation of various components easier to accomplish. There are 22 Wizards available in Visual FoxPro:
|Application||One to Many Report|
|Import||SQL Server Upsizing|
|Mail Merge||WWW Search Page|
|One to Many Form||Web Publishing|
In this chapter, you will learn about five of the 22 Wizards: the Application, Documenting, Setup, WWW Search Page, and Web Publishing Wizards.
In the discussion of these wizards, you will see that they all have a consistent user interface, which will make it easy during your future development work to use a new wizard that you have not seen before.
The Application Wizard creates a project and a project directory structure for an application. When the wizard finishes, the Application Builder is automatically run to enable you to add data, forms, reports, and other components to the application. Figure 27.1 shows the first screen of the Application Wizard.
You have three actions to take in this screen. First you enter the name of your application in the top text box labeled Project Name. The Project File text box is used to enter the name and path of the .PJX project file to be created. The final option is the check box labeled Create Project Directory Structure; checking this box will cause the Application Wizard to create a directory structure for your project.
After you choose OK, the Application Wizard will create the project directory structure and the project file. The wizard will put the application components into the project file, open the Project Manager for this new project, and show you the help file entry for the Developing Applications Using the Application Framework. The directory structure created by the Application Wizard is shown in Figure 27.2.
The Application Wizard directory structure is used to organize the pieces of an application. The data files go in the Data directory, forms go in the Forms directory, and the other components go in their respective directories. This directory structure will make it easy for you to keep track of the components of your application.
After showing you the help file entry for Developing Applications Using the Application Framework, the Application Wizard runs the Application Builder. I will discuss the Application Builder in a moment, but first let's see what the Application Wizard has built. Figure 27.3 shows the project built by the wizard.
Notice that the Application Wizard has created a free table named mytest_app. This table is used by the application framework to manage the forms and reports that are part of the application (see Chapter 18, "The Visual FoxPro Foundation Classes," for more information about this table). This table is in the root of the project directory structure and not in the Data directory.
Figure 27.4 shows the Classes tab of the project manager with the class libraries that were added by the Application Wizard.
There are seven class libraries in the project. The only one that is stored in the Libs directory is the project-specific library named ProjectName_app. The other libraries are part of the foundation classes in Visual FoxPro 6 and are stored in the FFC and Wizards directories under the Visual FoxPro home directory.
The project-specific class library has subclassed some of the classes from the _framewrk class library for this project.
Figure 27.5 shows the Code tab of the Project Manager.
The two program files shown in Figure 27.5 are the application's startup program (MyTest_app.prg) and a utility program for creating objects (SetObjRf.prg).
Figure 27.6 shows the Other tab of the Project Manager.
You can see that the Application Wizard has added quite a few files to the Other tab. There are two menus: MyTest_main is the main system menu for the application and MyTest_go is an added pad to the main system menu.
The text files listed in Figure 27.6 include a Config.fpw file for configuring the Visual FoxPro runtime environment for the application. Also, there are a number of header files for defining manifest constants for the application components.
Notice that there are two files named after the project. The first is a header file (.H) with manifest constants defined in it. The second is a text file for use with the project hook object that the Application Wizard has added to the project.
Under the Other files section, bitmap images (.BMP) and their respective mask (.MSK) files have been added. These bitmap and mask files are the images used for command buttons and other items have images on them.
This is the complete work of the Application Wizard. The wizard creates a project and populates it with the basic elements needed for a project, including a complete application framework.
After the Application Wizard has created the directory structure and project for a new application, the Application Builder is automatically run. Figure 27.7 shows the Application Builder form.
The Application Builder is a tabbed form with a PageFrame in it. The tabs of the PageFrame are labeled General, Credits, Data, Forms, Reports, and Advanced.
You will be shown these tabs in the order they appear in the form.
The General tab is used to enter general information about your application. The project Name is entered automatically by the Application Builder. You can enter an Image filename, or browse for one by pressing the ellipsis button beside the Image text box. Press the ellipsis button in the Icon box in the lower-right corner of the form to browse for an image file to serve as the application icon (it's okay if this is the same file you specified as the Image file).
The balance of the options in this tab are described in Table
|Common Dialogs||Splash Screen||When checked, will create a splash screen that is displayed during the application's loading process, unchecked suppresses the splash screen.|
|About dialog||Checked includes an About dialog on the help menu, unchecked excludes the About dialog.|
|Quick Start||The Quick Start screen is a menu form that enables the user to access the forms and reports without using the menu system. Checking this box includes a quick start form and unchecking the box excludes the quick start form.|
|User Logins||Checking this box requires that users log into the application using a user name and password. Unchecking the box excludes this feature from the application.|
|Application type||Normal||The application will run in the Visual FoxPro desktop. The main Visual FoxPro screen will contain the forms for the application.|
|Module||The application will be a module that is called from some other application.|
|Top-Level||The application runs outside of the Visual FoxPro screen as a top-level application under Windows.|
Figure 27.8 shows the Credits tab of the Application Builder.
On the Credits tab, there are only five items to be entered: Author, Company, Version, Copyright, and Trademark. You enter the text exactly as you want to see it in the About dialog.
The next tab is the Data tab, which is shown in Figure 27.9.
The options on this tab are described in Table 27.2.
|Datasource||Datasource||The names of the tables that hold the data for this application. This example used the Select button and chose the Testdata.dbc database that is included with the Visual FoxPro samples. When you select a database, all the tables in that database are included.|
|Form||By checking the box beside each table name, the Application Builder will use the Form Wizard to create a form for that table.|
|Report||This column is the same as the Form column, except it creates a report.|
|Form Style||This combo box offers nine form styles: Standard, Chiseled, Shadowed, Boxed, Embossed, Fancy, Stone, Flax, and Colorful. These styles affect the coloring and style of the forms created by the Form Wizard for the tables.|
|Report Style||Similar to the Form Style, this combo box offers five styles for reports: Presentation, Ledger, Executive, Banded, and Casual.|
|Select||Produces the File Open dialog to enable you to search for tables or databases on the disk drive and include them in the list of tables.|
|Clear||Clears out the list of tables to enable you to start over should you find you need to.|
|Generate||Generates a form or report for the selected table in the grid using the Form Style and/or Report Style selected with the combo boxes.|
The two buttons with the magic wands on them in the upper-right corner of the Data tab are used to run the Database Wizard and the Table Wizard, respectively. The second button (with only one browse window on it) runs the Table Wizard; the first runs the Database Wizard.
Figure 27.10 shows the Forms tab that is used to add forms that already exist to the application.
The first thing to do is to select the Add button and add the form named Video.scx, which is included with the Visual FoxPro samples. The Add button brings up the File Open dialog to enable you to navigate your disk drive and find the form you want to include in the application.
The Remove button can be used to remove the highlighted form from the application.
The Edit button is used to open the highlighted form in the Form Designer. If you choose to edit a form, you see the dialog box shown in Figure 27.11.
This dialog asks you if you want the Application Builder to add a mediator object to the form so that the form will function properly within the framework of the application. You typically answer Yes to this dialog so that the forms added to the application will make use of the features of the application framework. If you answer No to this dialog, you will see the dialog every time you edit the form within the Application Builder until you answer Yes.
The five check boxes on the right side of the Forms tab are described
in Table 27.3.
|Single Instance||Checked enables only one instance of the form to be open at a time, unchecked enables multiple instances of the form to be open.|
|Use Navigation Toolbar||Checked will include a navigation toolbar for the highlighted form, unchecked omits the navigation toolbar.|
|Use Navigation Menu||Checked includes a navigation menu for the highlighted form, unchecked omits the navigation menu.|
|Appear in File New Dialog||Causes the form's name to appear in the application's New dialog.|
|Appear in File Open Dialog||Causes the form's name to appear in the application's Open dialog.|
The next tab is the Reports tab, which is shown in Figure 27.12.
The Reports tab is similar to the Forms tab except that it deals with reports rather than forms. It is used to include existing reports in the application. The Add, Edit, and Remove buttons function the same way they do on the Forms tab.
The only option on the Reports tab is named Appear in Print Reports Dialog. Checking this box causes the highlighted report in the list to be included in the application's Print Reports dialog.
Figure 27.13 shows the last tab, Advanced, in the Application Builder.
The options that you can set using the Advanced tab include a Help File Name that will be included in the application. The ellipsis button to the right enables you to browse for the help file you want.
The Default Data Directory text box enables you to provide a path to the data that the application will use. The ellipsis button to the right enables you to browse for the directory you want.
The Menus box has two options in it, Standard Toolbar and Favorites Menu. Checking these options includes their respective components in the application.
The Cleanup button runs a routine to reconcile any changes you have made in the Application Builder with the project file.
Click the OK button to complete the Application Builder. This might bring up the dialog shown in Figure 27.14.
You get this dialog if you have never selected the Generate button on the Data tab of the Application Builder, which means that your forms and reports were not created. Answering Yes to this dialog causes the Application Builder to generate those files for you now.
After you're finished with the Application Builder, you should build the application and mark the Recompile All Files option. In the ongoing example, the application is named the same as the project, MyTest.app. After the application is built, you can run it from the command window by typing DO MyTest.app.
Figure 27.15 is the first screen you see in this application.
I chose to run the Customer form that the Application Builder created for me. Figure 27.16 shows the Customer form.
Notice that there is a navigation toolbar in the toolbar area of the screen; this toolbar is there because I told the Application Builder that I wanted one for this form. The toolbar buttons can be used to navigate in the Customer form.
Explore the application that the builder created to find out more about the features of the resulting application. You can also refer to Chapter 18 to learn more about the way this application functions.
The Documenting Wizard is used to create system documentation for a Visual FoxPro project. The documentation produced optionally includes formatted source code listings, action diagrams, cross-referencing of variables, fields, and properties, a listing of all files that compose the project, and tree diagrams showing the calling order.
Figure 27.17 shows the first step in the Documenting Wizard.
In the first step, you identify the project file for which you want to produce documentation. I used the project that I just built in the Application Wizard and Builder. After you identify the project, press the Next button to proceed to step 2. Figure 27.18 shows the form for step 2.
The Help button gives you a help screen specific to the step you
are on and the Cancel button cancels the documenting of the project.
In step 2 you determine how the capitalization will be applied
to the source code listings and other diagrams produced later.
The choices are listed in Table 27.4.
|UPPERCASE||All keywords will be in uppercase letters in the source code listings.|
|lowercase||All keywords will be in lowercase letters in the source code listings.|
|MixedCase||All keywords will be in mixed case letters in the source code listings.|
|No Change||Keywords will not be altered from the way they appear in the actual code in the source code listings.|
Table 27.5 describes the capitalization options for the symbols
in the source code listings.
|UPPERCASE||All symbols will be in uppercase letters in the source code listings.|
|Lowercase||All symbols will be in lowercase letters in the source code listings.|
|Match First Occurrence||The capitalization of the symbols will be determined by the first occurrence of each symbol in the project code.|
|No Change||Symbols will not be altered from the way they appear in the actual code in the source code listings.|
Figure 27.19 shows step 3 of the Documenting Wizard, which controls the indentation of the source code listings.
In step 3 you set the type of indentation that will be used to format the source code listings. The Type of Indent box enables you to choose Tabs or Spaces. If you choose Spaces, you will need to set the number of spaces to use for one level of indentation.
The other box, Text to Indent, provides check boxes to determine what text will be indented. The options you have are Comments, Control Structures, and Lines Continued by a Semicolon. The Comments option is self-explanatory. The Control Structures option controls the indentation of IF...ENDIF, DO CASE...ENDCASE, DO WHILE...ENDDO, FOR...ENDFOR, SCAN...ENDSCAN, and PROCEDURE/FUNCTION...ENDPROC/ENDFUNC constructs. Checking the Control Structures check box will indent the code inside of these program constructs.
The Lines Continued by a Semicolon check box determines whether the continuation lines using a semicolon will be indented under the first line of the command statement.
Figure 27.20 shows step 4 of the Documenting Wizard.
Step 4 is used to set the files for which you want headings added. The headings that will be added are comment blocks about the code that follows the heading. Using headings in your formatted source code listings can make the source code easier to read and understand.
The choices of files to add headings to are Files, Procedures, Class Definitions, and Methods. Files refers to all files that are not Visual FoxPro program files, such as .H header files or .TXT text files. Procedures includes all .PRG files and the PROCEDURE or FUNCTION declarations inside those .PRG files. Class Definitions includes those classes created with the DEFINE CLASS command and those in visual class libraries. Selecting Methods will put a comment header into each method code.
Figure 27.21 shows step 5 of the Documenting Wizard.
Step 5 is where you determine what documentation will be produced by the wizard. You have five pieces of documentation that you can select. In Figure 27.21 I selected all five. These pieces of documentation will be described in detail later in this section; for now, select them all and select Next to move on to step 6. Figure 27.22 shows the step 6 form.
In step 6, you determine where the documentation files will be created and whether you want a Cross-Reference of Keywords produced and/or want to Run Analyzer. I elected to put all the documentation in a single directory and to produce the Cross-Reference Keywords and to Run Analyzer.
When you click the Finish button, the Documenting Wizard begins to produce the documentation you requested. The process of producing the documentation can take a few minutes depending on the size of your project.
When the Documenting Wizard has finished producing the documentation, the Visual FoxPro Code Analyzer is run (if you requested it). Figure 27.23 shows the Code Analyzer on the Symbols page.
The list in the upper-left corner shows all the symbols found in the code. Highlighting an item in this list causes the grid below it to show all the places that the highlighted symbol is referenced. Clicking on one of the reference locations in the grid opens the editor for that item and highlights the occurrences of the symbol. Figure 27.24 shows what I saw when I selected AGAIN as the symbol and then clicked on _error in the locations grid.
Notice in Figure 27.23 that there is a Line column in the grid.
This column shows you the line number that the selected symbol
appears on in the procedure. The File Name column of the grid
shows you the name of the file that the procedure is found in.
The Flag column shows a single character value that represents
the Type filed in the project's file. Table 27.6 lists the possible
values for the flag column.
|Visual Class Library|
The Hierarchies tab enables you to see the program Calling tree or the class diagram for the application. The calling tree shows what procedures call what other procedures and the class diagram shows the parent class to subclass relationships. Selecting the Close button closes the Code Analyzer.
Figure 27.25 shows a sample of a formatted source code listing with the header comments that were inserted by the Documenting Wizard.
Figure 27.26 shows a sample of an action diagram produced by the Documenting Wizard.
To see the lines that mark out the logical constructs in the code, I had to change the font for the edit window to FoxFont 9 point. With any other font, the lines don't show correctly.
Figure 27.27 shows the symbol cross-reference listing produced by the Documenting Wizard.
The columns in the cross-reference are the symbol name, the flag used by the cross-reference program to produce this listing, the line number that the symbol appears on, and the filename that the symbol appears in.
Figure 27.28 is a sample of the tree.lst file produced by the Documenting Wizard to hold the tree diagram.
The section of the tree diagram shown in Figure 27.28 is the class hierarchy. The other section is a program calling stack listing.
Figure 27.29 shows the files list produced.
The process of installing a distributed Visual FoxPro application can be a complex one. There is the Visual FoxPro runtime library to be installed and there are several supporting files to be installed and registered on the target machine.
Thankfully, Visual FoxPro provides the Setup Wizard to create installation disks. Figure 27.30 shows the first dialog in the Setup Wizard.
This dialog is only seen if the distribution directory does not exist. The dialog is informing you that the directory for storing the distribution files for the Visual FoxPro runtime library does not exist. The dialog offers you three choices:
- Create Directory-Creates a directory named Distrib under your Visual FoxPro home directory.
- Locate Directory-Enables you to locate the directory that you want the Setup Wizard to use.
- Cancel-Cancels this run of the Setup Wizard.
After the Distrib directory is created, the Setup Wizard moves on to step 1 of the process, as shown in Figure 27.31.
I selected the directory for the project I created earlier with the Application Wizard and Builder. In order to use the Setup Wizard for a project, you must create a directory structure on your machine that exactly represents the directory structure that the target machine will require. Then you must move all your application files to their appropriate directories within that structure. The Setup Wizard will create setup disks that mirror the directory structure you create. In step 1 of the Setup Wizard, you enter the path to the directory structure for the application.
Figure 27.32 shows step 2 of the Setup Wizard.
In step 2 you specify what components should be included in the
setup process. The six options are described in Table 27.7.
|Visual FoxPro Runtime||VFP6r.DLL, the Visual FoxPro runtime library. This file is required if your application will be run on machines that do not have the full version of Visual FoxPro installed on them.|
|Microsoft Graph 8.0 Runtime||Required if your application has forms that use the Microsoft Graph 8.0 control for graphing data.|
|ODBC Drivers||Required if Visual FoxPro is accessing data through ODBC drivers. Checking this box will produce the ODBC Driver dialog so that you can select the particular ODBC drivers you need.|
|COM Components||Adds COM components in .EXE or .DLL files. You need to use this option to select any COM components that your application uses. Selecting this box brings up a dialog in which you can choose the COM components that you need.|
|ActiveX Controls||Required if your application makes use of any ActiveX controls. Selecting this box brings up the ActiveX Control dialog in which you can select any ActiveX controls that your application requires.|
|HTML Help Engine||Includes the Microsoft HTML help engine for use with any help files your application might use.|
After you identify the components required by your particular application, you can select Next to move on to step 3 (see Figure 27.33).
In step 3 you create the directories to hold the setup files for your application. The directory that you specify in the Disk Images Directory text box will have a number of subdirectories in it that depend on which setup types you select with the check boxes below that text box.
The three types of setups that you can choose from are 1.44 MB 3.5-inch, Websetup (compressed), and Netsetup (uncompressed).
The first setup type, 1.44 MB 3.5-inch, will create a set of subdirectories under the main setup directory named Disk1, Disk2, and so on. These directories will contain disk images for the disks in the setup set. After the directories have been created, you can copy Disk1 to the first disk, Disk2 to the second disk, and so on for all the disks required by the setup.
The Websetup (compressed) option will create one directory under the setup directory named Websetup. The Setup Wizard will put a compressed copy of all the setup files in this directory. These files can be used by executing the Setup.exe file that will reside in the directory. The files for this type of setup will be compressed so that they are more quickly downloaded from the World Wide Web with an Internet browser program.
The last setup type is Netsetup (uncompressed). This type will create a subdirectory named Netsetup under the setup directory and will put all of the files required to run the Setup.exe program in an uncompressed format. This option is designed for installations across a LAN. You can also use this type of setup to create CD-based installations: just copy the Netsetup directory to your writable CD drive. The user would insert the CD and run the Setup.exe file from the CD.
Figure 27.34 shows step 4 of the Setup Wizard.
Step 4 enables you to specify the title text that will appear in the setup program's window during installation, copyright information to appear during the setup process, and an executable file to be run at the end of the installation. After you specify this information, select Next to move to step 5.
Figure 27.35 shows step 5 of the Setup Wizard.
In step 5 you designate the Default Directory that should be used for installing the application on the target machine. You also designate the Program Group to which the application should be added.
The option buttons near the bottom of this screen enable you to control whether the user is allowed to alter the Target Directory and Program Group or the Directory Only.
Selecting Next moves you to step 6 (see Figure 27.36).
In step 6 you can alter the target directory for any particular file or files included in the setup process. You can also add certain files to the program group as icons so that they can be executed separately from the application. The last option is to designate the ActiveX components in your application so that they will be properly registered on the target machine.
You use the grid on this dialog to accomplish all the desired operations. Click on the file you want to alter, and then use the Target Dir column to establish the directory in which the file should be installed. Use the PM Item check box column to add the file to the program group. Finally, use the ActiveX check box column to identify the ActiveX components that must be registered on the target machine.
Select Next to move to the final step (see Figure 27.37).
You have two options in the finish step of the Setup Wizard: Generate a Web Executable File and Create a Dependency (.DEP) File.
The option for creating a Web executable file is only enabled if there is an ActiveDoc component in your application.
Figure 27.38 shows the progress dialog you see after clicking Finish in step 7.
This dialog informs you of the progress made in creating the setup disk images you requested. When the Setup Wizard finishes creating the disk images, you see the dialog in Figure 27.39.
In this dialog you can see how many disk images were created. For each disk, you can see how many files are on it, the size of the files, the bytes left available, and the percent of the disk used by the files.
The report that is available with the Preview Report and/or Print All Reports buttons is shown in Figure 27.40.
This report lists all the installation images created through the Setup Wizard. It shows every file that is on every disk and the expanded and compressed size for each file, and can be stored as documentation of the Setup Wizard's finished product.
The Visual FoxPro Setup Wizard will create a directory in which to store the Visual FoxPro runtime files for distribution. In the preceding example, the directory was designated to be named Distrib and to reside under the Visual FoxPro home directory.
If you ever upgrade your version of Visual FoxPro, you will need to clear out the Distrib directory so that the Setup Wizard will re-create it with newer runtime files for the newer version of Visual FoxPro.
The World Wide Web is the buzzword of the day. The question of whether a particular development language can have its applications deployed on the Web is ever present. The next two Wizards you will examine both have to do with the Internet. The first is the WWW Search Page Wizard, which enables you to create a Visual FoxPro-based search page for the Web. The second is the Web Publishing Wizard, which enables you to publish data in an HTML document for the Web.
Both of these wizards require that you use a Web browser to view their products.
The WWW Search Page Wizard also requires that you have an Internet server set up to use the search page that is created. The setup of an Internet server is beyond the scope of this chapter. This example will use the Microsoft Internet Information Server software running on Windows NT Server 4.0.
You can use Microsoft's Personal Web Server to build and test your Web search pages. This enables you to work with the WWW Search Page Wizard without having the full IIS installed.
When setting up an Internet server, one of the things you need to do is identify the root directory for the WWW server. In this installation, the directory is D:\InetPub\WWWRoot. You need to know the WWW root directory on your Internet server because you will need to copy some files into it for the Visual FoxPro Internet server application to run properly.
The WWW Search Page Wizard will create three files for you. These files are named YourName.HTM, YourName.HTX, and YourName.IDC. You will need to copy these three files into the WWW root directory for your Internet server application.
One other file must be placed in the WWW root directory: the VFPCGI.EXE file is found in the Tools\Inetwiz\Server directory under your Visual FoxPro home directory.
You start the WWW Search Page Wizard by choosing Tools, Wizards, All. Figure 27.41 shows the dialog you see with the WWW Search Page Wizard selected.
Click the OK button to continue with the WWW Search Page Wizard. Figure 27.42 shows the first screen of the wizard.
There is nothing to do on the first screen; it is just a welcome page. Select Next to move on to step 1 of the Wizard (see Figure 27.43).
This figure shows the selection of the Customer file in the Visual FoxPro samples directory.
Visual FoxPro 6 installs its samples in a different place than Visual FoxPro 5.0 did. The samples for all of the Visual Studio products are installed together. The new _SAMPLES system memory variable holds the path to the Visual FoxPro 6 sample files. You can display this path by typing ? _SAMPLES in the command window and reading the output on the screen.
The Browse button enables you to navigate the disk drives to find the table you want.
The table you select will be used by the Search Page to retrieve data. After you select the table, select Next to go on to step 2 (see Figure 27.44).
In this step you identify the index for your table that you want the search to use. The indexes shown are those that exist for the selected table. If you want to use some other index, you must create that index before you run the WWW Search Page Wizard.
I chose the Company index on the Customer table and then selected Next to go to step 3, which is shown in Figure 27.45.
The first option in this step is the Search Page Title. The title will appear in the browser's title bar and will also appear centered on the page below the title bar.
The second option is the Search Page Description that will appear centered on the page below the title. This description can be used to describe how to use the search page. Although the title should be short and to the point, the description can be longer and more informative.
When you have entered your title and description, select Next to proceed to step 4 (see Figure 27.46).
In this step you specify the graphics elements you want on your search page. The Background Image button can be used to navigate the disk drives to locate the image you want. The background image will tile the background of the search page.
The Header Image button lets you locate a .GIF or .JPG file to be used in the header of the search page.
The Provide the Ability to Download the Result Set as File check box presents the option for downloading the results to a file to the user of the search page.
You don't need to use any images on your search page, but images sure make the page more interesting. After you are finished with the search page options, select Next to move on to step 5, which is shown in Figure 27.47.
In this step you identify the fields that you want to send back on the results page of the search. You are limited to five fields using the WWW Search Page Wizard. After you select the fields you want, select Next to move on to step 6 (see Figure 27.48).
This page is similar to step 4 where you set the options for the search page, with the key difference that here you are setting up the page for the results of the search. The options for images are the same as they were for the search page in step 4.
In step 6 there are two more options to set:
- Maximum Records-Controls the number of records to be returned on the results page.
- ODBC Data Source-The datasource you are using for the search. It does not need to be specified if you are using local Visual FoxPro data.
When this step is completed, select Next to go to step 7, which is shown in Figure 27.49.
This This is the last step in the WWW Search Page Wizard. Clicking the Finish button creates your search page files. You see a dialog asking what name to save your search page files under (see Figure 27.50).
Use the dialog to navigate to your WWW root directory and enter the name you want your search page to be saved as in the HTML File text box. After you enter the name, click Save.
That completes the WWW Search Page Wizard. Now all you have to do is get the search page working.
The search page created with this wizard uses a technology known as Common Gateway Interface (CGI) to enable the search page to cause a Visual FoxPro data server to run a query and produce a results page. The VFPCGI.EXE file is the CGI engine for the Visual FoxPro server application.
Before you can use your search page, you must run the Visual FoxPro Server.app file found in the Tools\Inetwzi\Server directory under your Visual FoxPro home directory.
Figure 27.51 shows the dialog you see the first time you run Server.app.
In this dialog, you must specify the path to the WWW root directory in the HTTP Server text box. The Scripts text box is used to enter the path to the WWW server's scripts directory. In the Path edit box, you must enter the path to the data table that your search page uses. After you set these items and click OK, you see the form shown in Figure 27.52.
Although this form looks barren right now, it will get busier as you use your search page.
To use your search page, you must have an Internet server running. You can then use your favorite Internet browser to navigate to //YourServerName/YourSearchPageName.HTM. Figure 27.53 shows an example search page in IE.
Entering the letter A and clicking Search results in the page shown in Figure 27.54.
The results page shows you the customers with a company name that begins with the letter A. Figure 27.55 shows the WWW Data Server Log after a couple of searches have been done.
The three files created by the WWW Search Page Wizard-MyTest.HTM, MyTest.IDC, and MyTest.HTX-are, respectively, the search page HTML document, the query template for the WWW Data Server application, and the template for the HTML results document that the server will create.
The Web Publishing Wizard enables you to publish data on the World Wide Web. Unlike the WWW Search Page Wizard, it does not create a search page for selecting data; rather, it simply publishes the data in an HTML file.
Figure 27.56 shows the first step in the Web Publishing Wizard.
In this step you identify the table and the fields from that table that you want to publish. The ellipsis button can be used to locate the table on the disk drive. I chose the Customer table in the Testdata database, which is in the Visual FoxPro samples directory.
When you have chosen the table, you can use the mover lists to select the fields to be published. After the fields are selected, select Next to continue to step 2 (see Figure 27.57).
Use the mover lists to select the fields you want to use to order the data. Use the mover buttons in the list on the right to set the sort hierarchy. The Ascending and Descending option buttons will affect the currently highlighted field in the list on the right.
After the sorting is set up, select Next to go on to step 3, which is shown in Figure 27.58.
In this step you determine the style for your published data. The list titled Data Layouts is used to select a layout for the data. As you select different styles, the graphic in the upper-left corner reflects what each style will look like.
The list titled Visual Styles is used to select the background graphic to be used on the published page.
Clicking the Preview button shows your published page in the Internet browser installed on your computer. You can use Preview to try out different layouts and styles until you see the one you want.
Options and Advanced enable you to fine-tune the HTML settings if you are familiar with HTML.
Select Next to move on to step 4, as shown in Figure 27.59.
In this step you enter a title for the Web page, and then you have four choices:
|Save Web Page for Later Use||Saves the .HTM file for you to use later.|
|Save Web Page and Modify It in a Text Editor||Saves the HTML document and immediately opens it for editing in a text editor.|
|Save Web Page and Open It in a Browser||Saves the HTML document and opens it in your Web browser for viewing.|
|Create Script for Generating Web Page||Creates a program that will dynamically create the HTML document.|
For the example, I chose the last option to create the script and then clicked Finish.
The Save As dialog appears to name and place the file. I placed mine in the WWW root directory and named it PubTest.prg.
Figure 27.60 shows the program that was generated in the Visual FoxPro editor.
To use this program, you simply have to issue DO programname in the command window. Figure 27.61 shows the resulting HTML document viewed in IE.
© Copyright, Sams Publishing. All rights reserved.