Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
CREATE CLASS
, MODIFY CLASS
These commands open the Class Designer (CD).
CREATE CLASS [ ClassName | ? ]
[ OF ClassLibraryName | ? ]
[ AS ParentClassName [ FROM ParentClassLibrary ] ]
[ NOWAIT ]
MODIFY CLASS [ ClassName | ? ]
[ OF ClassLibraryName | ? ]
[ AS ParentClassName [ FROM ParentClassLibrary ] ]
[ METHOD cMethodname ] [ NOWAIT ] [ SAVE ]
When you create a class, you need to specify at least three pieces of information: the name to assign the new class, a library (VCX) in which to store the new class, and the class on which the new class is based. If it’s based on a user-defined class, you may need to specify the library containing that class, too. MODIFY CLASS
doesn’t need quite as much information—just the name of the class to edit and the class library where it can be found.
The two commands behave differently when you don’t provide all the necessary information. Not surprisingly, CREATE CLASS
assumes you want to create a new class and displays a dialog labeled “New Class” that lets you specify the name of the new class, the base class, and the library in which to store the new class. An incomplete MODIFY CLASS
, on the other hand, brings up a special form of the File-Open dialog that lets you look inside existing class libraries and choose one of those to edit. In fact, we often use MODIFY CLASS
just to see what’s out there.
We were really surprised to find that MODIFY CLASS
includes the AS and FROM clauses, so we checked it out. If you use AS and specify a different parent class than the one on which the one you want to edit was originally based, you get prompted to overwrite the old definition with a new one. (That is, if you say MODIFY CLASS
MyObject AS Check box and you’d originally defined it as Spinner, the old definition gets discarded in favor of the new one.) The setting of SAFETY doesn’t matter in this case—you always get prompted. Good thing.
The METHOD clause is a cool one—one added with developers in mind. Issuing this command from the command window brings you right into the code window with the method you specify ready for editing. When we're in the middle of the code-test-debug cycle, having this command to scroll up to in the command window and re-run is so much faster! |
NOWAIT and SAVE let you use these commands in a program and have the CD behave sensibly. With NOWAIT, program execution continues, leaving the CD open and available. SAVE lets you click outside the CD without having it shut down abruptly. You only need SAVE if you don’t have NOWAIT.
CREATE CLASS MySpinner AS Spinner OF Controls