FoxProFoxPro Developer's Conference '94 |
Session
124
Power
Tools eXtensions:
Rebuilding The Power Tools
Andrew Ross MacNeill
PC Edge Inc.
Introduction
When FoxPro 2.0 was first released, many considered its Power Tools to be state of the art. They were powerful and they provided something to the xBase development world that hadnt been seen for quite a while. When FoxPro 2.5 was released on both DOS and Windows platforms, the Power Tools didnt change. Under Windows, they received a graphical interface but the functionality did not change a great deal. At the same time, however, other development products were making use of new technology and ideas to create more efficient screen and menu design tools. With the release of dBase for Windows, these new concepts have been brought into the xBase world, leaving the FoxPro Power Tools with a slightly dated look to them.
While Microsoft is sure to change the tools in FoxPro 3.0, developers will still be using FoxPro 2.x for some time to come for various reasons: legacy applications and cross-platform development, to name a few. Does this mean developers are stuck with the older Power Tools? Not necessarily. Thanks to Ken Levy, of GENSCRNX fame, a new tool has been released into the Public Domain for FoxPro 2.x. It is called PTXEDT but the full name is Power Tools Extensions Editor. On its own, the PTX Editor is a faster and easier way to deal with code within the power tools. But just as GENSCRNX offers extendability through its drivers, the real strengths of PTXEDT are in its extensions. It is called PTX Editor because it is just that. PTXEDT is an EDITOR for the Power Tools; but just as Visual Basic allows developers to create custom VBXs, PTXEDT allows developers to write their own PTXs and here is where the fun really begins.
A Roadmap of the PTX Editor
First, lets get an idea of what the basic PTX Editor does and how it does it. The first thing to remember is that all Power Tools in FoxPro (with the noteable exception of the RQBE) are simply DBF tables with different file extensions. This means as developers, we are able to USE, BROWSE, DELETE, APPEND and SORT screen files (SCX), menu files (MNX), report files (FRX) and even project files (PJX). This knowledge is also important when creating drivers for GENSCRNX and GENMENUX, so it is not a coincidence that a lot of the work being done on the PTX Editor are being written by developers who have written code for the GENX products.
Since the Power Tools simply create tables, what the PTX Editor does is provide a newer and perhaps, cleaner, way of looking at the information contained within these tables. When the PTX Editor screen appears, it displays several different objects that may be confusing to the first time user. Lets step through each part of its interface.
The Close and Save buttons allow developers to close the PTX Editor
The Beautify button gives Windows developers the opportunity to "beautify" individual snippets of code using FoxPros BEAUTIFY.APP. This can make it easier when attempting to read the various snippets.
The Verify button is perhaps one of the most useful. When developers create code within a screen, the only way to determine if there are any compilation errors is to generate the screen, compile the SPR and then look at the ERR file that is generated. The Verify button will compile individual snippets and display any errors without performing any code generation. This makes it easier to debug specific code. Another neat feature of the Verify button is to watch the traffic lights change as it verifies your code.
The Edit button allows the user to expand the text editing window into a normal FoxPro text window so that editing may be done at the users preference settings. For expressions, the Edit button activates the FoxPro Expression Builder dialog.
The Object popup list shows every object in
the Power Tool table by giving it a special name. This name
is very often the variable name or the type of object it is.
By selecting different objects within the list, it is
possible to look at different code snippets.
Another neat way of choosing another object with screens is
by clicking on the object with the right mouse button while
the PTX Editor screen is shown.
The Snippet popup list shows all of the snippets that are specific to an object. If a particular snippet has code within it, it is market with a dash or hyphen. The snippet list uses some newer terms than what some developers may be used to. This following table shows the Screen Builder equivalents:
PTX Editor | Screen Builder |
ValidationRule | Valid |
FocusMessage | Message |
WhenRule | When |
General | Comment Snippet |
ErrorMessage | Error |
The actual PTX Editor Text Editing window offers an additional feature that is handy for cross-platform development. In regular FoxPro, a user has to make changes in both platforms when code snippets need to change. While these changes may be transported, it still makes for a longer development cycle than making changes in a single place. The PTX Editor solves this problem by automatically reconciling the code snippets across the platforms. Changes can be made in a single platform and they will be applied to all platforms contained in the power tool.
The Procedure popup list may be changed to identify an expression where applicable.
Installing PTXEDT
PTXEDT should be unzipped (using PKUNZIP) in a separate directory. When decompressed, the directory contains the following base files:
PTXEDT.APP | PTX Editor |
PTXEDT.DBF/FPT | PTX Database This table is used to identify the various PTXs that may be run from the PTX Editor. |
Installing PTXEDT is not as easy as installing GENSCRNX where FoxPro has a system variable that can be changed. PTXEDT must be called by issuing a normal FoxPro command, "DO PTXEDT". This can and should be automated to some degree, by having PTXEDT run when the user clicks on the right mouse button.
ON KEY LABEL RIGHTMOUSE DO PTXEDT.APP
Once this command has been issued, PTXEDT will appear when the right mouse button is clicked. However, because it is implemented with a single FoxPro KEY LABEL statement, it can be "uninstalled" with a simple POP KEY ALL command.
PTX Internals
The PTX Editor is a powerful tool but on slower machines, its benefits are diminished slightly. This is because of what it does internally.
In order that it may manipulate the table and still display the screen or power tool in the background, PTXEDT makes a copy of the Power Tool table. For screens and reports with many objects, this may take a few seconds. What also happens is that because it has to COPY the table, it closes the Power Tool for an instant. This results in a noticeable "flash" on the screen. If a developer has a particularly slow development environment, this COPYing of files may get annoying.
The table that PTXEDT creates is called PTXEDT.DBF and has a specific structure that allows developers to create new PTXs. When PTXEDT loads, it runs various PTXs at different stages. This allows developers to write PTXs that may be run before the main PTX EDT screen appears.
The structure of the PTXEDT.DBF is described below.
Field Name | Type/Length | Description |
PTXCODE | N/3 | Code that identifies when
the PTX is run. 1 - Standard PTXs |
PTXNAME | C/20 | PTX Name that appears on list |
PTXPROGRAM | M | The application that is run when the user chooses the PTX. If the application is not found in the path or the field is empty, the PTX will not show up on the list. |
PTXCLASS | M | The CLASS of PTX. Classes identify what Power Tool a PTX may be used with. Classes can be one of the following:
* - All Power Tools PTXs can be used for multiple classes by placing commas between classes. |
PTXs: Opening Up The Power Tools
The basic PTX editor provides a cleaner interface in dealing with code within the Power Tools and it also solves a basic problem with cross-platform development. However, the biggest benefit of using PTX EDT is in the popup list of PTXs.
A PTX is an acronym for Power Tools eXtension. Just as Visual Basic developers use VB to create custom VBXs, FoxPro developers write PTXs within FoxPro. A PTX is simply a FoxPro program or application that provides additional functionality to the power tools. They can be specific to a particular tool, such as the Screen Builder, or available at all times.
Why have a PTX at all? With basic FoxPro, it may not be that big a requirement. However, with the introduction of GENSCRNX and its various drivers, it can be very difficult for a user to remember all of the possible directives or commands available with a particular driver or even GENSCRNX itself. As a result, many of the first PTXs provided functionality for various GENSCRNX drivers.
When PTXEDT is first run, it automatically adds two PTXs for the user to see. The first is called "About" which displays a message about the version of PTXEDT that is being run. The other is "CONFIG" which displays the users FoxPro configuration file (CONFIG.FP) so that it may be modified. As PTXs are simply FoxPro programs, the CONFIG PTX is made up of a single statement:
MODIFY COMMAND SYS(2019)
The best way to identify what a PTX is capable of is to look at several PTXs that are available in the Public Domain. The following PTXs were written specifically for GENSCRNX or GENMENUX drivers.
WIN3DPTX.APP | Windows 3D Driver PTX This PTX was written by Ken Levy for use with his GENSCRNX 3D driver. It provides a interface by which the user is able to select the type of 3D effect to use for a particular object. Of particular interest is the interface for specifying 3D effects for lines and boxes. The slider on the screen will show an example of the effect on a box. This effect changes as the user moves from right to left on the slider. As the GENSCRNX 3D driver is a Windows-only driver, this PTX is also platform-specific for Windows. |
INTL/PTX | Steven Blacks INTL
Toolkit PTX This PTX was written for use with Steven Blacks INTL Toolkit. The INTL Toolkit provides multilingual support for FoxPro through the use of a GENSCRNX driver. The PTX provides an interface through which users can specify the various directives that control how the driver runs. For Text and SAY objects, the INTL/PTX shows the existing translation in a list box. This gives developers a good indication of how wide a particular object needs to be to hold the various translations. |
GENSCRNX/PTX | GENSCRNX PTX This PTX provides access to the various GENSCRNX directives. In GENSCRNX, there are so many directives that is easy to forget the proper syntax for a particular directive. This PTX uses check boxes and lists to make it easier to implement the various directives. |
GENMENUX/PTX | GENMENUX Power Tools
eXtension Just as the GENSCRNX/PTX provides access to the GENSCRNX directives, this PTX provides the same functionality for GENMENUX. |
TABS/PTX | TABS Window Driver PTX TABS is a GENSCRNX driver designed by Steven Black to provide "page frames" or tabs in FoxPro screens. As with most GENSCRNX drivers, there are many directives that provide additional features. This PTX provides an interface to the various directives. |
The above examples may show PTX Editor as a tool for GENX users. Advanced GENX users may already know all the directives but by providing a PTX for a driver makes it easier to share the knowledge and the benefits that a PTX provides. Upcoming PTXs show a different side of PTX Editor, as a tool that can make overall development easier and ease the learning curve to newer development tools.
This next set of PTXs are designed to push the FoxPro 2.x into more productive tools by providing similar functionality as to what users can see in dBase for Windows, and other tools from Microsoft.
POPPTX | Popup PTX POPPTX is a special kind of PTX that runs before the main PTX Editor screen appears. It displays a popup menu where the mouse was last clicked and shows a list of PTXs that can be run directly, without using the main PTX Editor screen. This functionality makes PTX EDT act similar to the right mouse clicks available in Access and Visual Basic. |
FMT/PTX | Text Styles PTX The basic PTXEDT doesnt provide a mechanism for users to change object text or formatting; only code snippets are able to be changed. FMT/PTX provides an interface similar to the one in other products for controlling the appearance of objects. As well, FMT/PTX introduces "styles" to FoxPro, allowing developers to identify a specific format as a "style" and then applying the style to other objects. This is similar to "styles" in Word and other MS products. |
PROPS/PTX | Properties PTX It seems that as Windows 95 approaches, every product is offering "property sheets" as a means of changing the various attributes of objects. The Properties/PTX is no different. It displays a property sheet for any object in a FoxPro Power Tool (Screen, menu, project or report) and allows the developer to change the property. The property sheet is similar to those seen in Visual Basic and Access. |
All of the PTXs described here are PUBLIC DOMAIN, meaning that there is no charge in using them.
A New Generation of FoxPro 2.x Tools
One of the things that PTX EDT has done is extended the lifespan of the FoxPro 2.x Power Tools. While many developers will jump to the leading edge of software development and use the new FoxPro when it becomes available, many developers will still have to use FoxPro 2.x for daily work. PTXEDT makes it possible to introduce tools to 2.x that act similar to leading edge products. Obviously, there will come a day when FoxPro 2.x is no longer used, but considering that many applications will have to wait for a full cross-platform version of the new FoxPro, PTXs can offer some truly innovative solutions for the problems that developers may have today and tomorrow.
One such example is the new Menu Editor, a Public Domain product. This Menu Editor addresses many of the shortcomings of the existing FoxPro Menu Builder by providing an interface similar to that of the menu builder in Microsoft Access. This allows developers to move menu options between submenus and have a greater degree of control.
What else is available? We only have our imaginations to ask...
Power Tools eXtensions
(c)1994 Andrew Ross MacNeill