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.
APPEND GENERAL
, MODIFY GENERAL
These two commands work with a table’s ActiveX-based general fields. APPEND allows the addition of new data or the erasure of a field. MODIFY displays the field for editing or viewing.
APPEND GENERAL FieldName
[ FROM FileName | FROM MEMO MemoField ]
[ DATA cDataString ]
[ LINK ]
[ CLASS cClassName ]
Parameter |
Value |
Meaning |
FieldName |
Name |
Name of the general field where the data is placed. |
FileName |
Name |
Source of the data, if data is added from disk. |
MemoField |
Name |
VFP 3/Mac only: imports picture fields into general fields. |
cDataString |
Character |
An initial data string (like PARAMETERS in FoxPro) to send to the application. Many OLE servers accept CF_TEXT formatted strings and use them as their initial data. |
cClassName |
Character |
The OLE Class name, as listed in the Registry. |
It's a little-known fact that APPEND GENERAL FieldName with no further arguments erases the data contained inside the general field. |
The DATA keyword allows your application to squirt a little data into the general field. The most typical format for this data is called the CF_TEXT format, which is similar to the tab-delimited text format of the EXPORT and COPY commands: individual fields are separated with tabs, individual records with a carriage return and line feed pair. The example below demonstrates the creation of a simple graph with data preformatted in this fashion.
The CLASS keyword allows you to specify programmatically which OLE object is to be inserted into the general field. You can choose from the same items available from the “Insert Object” menu pad when working interactively. The trick to getting the right item is to determine what the class should be called. You can find these in your documentation or in the Registry under HKEY_CLASSES_ROOT. This clause can be used to override the default ActiveX server if more than one is installed on your system (for example, if you work with several programs that edit BMP files) or if the extension of the file is not the standard extension (such as DOC for word processing documents) used for the ActiveX server.
The LINK keyword is used to determine if the data should be embedded within the general field or linked to it. The advantage of embedding is that no link to the original file is retained, and changes made to the object are retained only within the copy in the table. The disadvantage of this method is that those changes cannot be shared with other applications. For example, the company logo bitmap might be modified in a paint program; if the copies stored in tables are linked, they too will immediately display the changed image. More information on general fields is located in “DBF, FPT, CDX, DBC—Hike!”
MODIFY GENERAL FieldName1 [, FieldName2... ]
[ NOMODIFY ]
[ NOWAIT ]
[ WINDOW DefinitionWindow ]
[ IN WINDOW ContainerWindow] | IN SCREEN
| IN MACDESKTOP ]
Parameter |
Value |
Meaning |
FieldNamen |
Name |
Specifies the field name(s) to be displayed. |
DefinitionWindow |
Name |
Specifies the window whose characteristics (size, color scheme, close box, whether it floats) are duplicated in the window created to display the general field. |
ContainerWindow |
Name |
Names the window in which the general field editing window is created and in which editing takes place. |
MODIFY GENERAL
is very similar to the MODIFY MEMO
command, except the data to be edited is visual rather than textual. In general, we feel we’ll be avoiding this command in applications, since we can do most of the same things, and with finer control, with an OLEBoundControl placed on a form. From the command line, it’s a handy way to view or edit the contents of a general field.
More information on OLE, COM and ActiveX is located in the “Active-Something” section in the back of the book.
#DEFINE tab CHR(09)
#DEFINE crlf CHR(13)+CHR(10)
LOCAL cTestData
cTestdata = "" + tab + "X-Axis" + crlf + ;
"Command" + tab + "431" + crlf + ;
"Function" + tab + "332" + crlf + ;
"Property" + tab + "211" + crlf + ;
"Method" + tab + "43" + crlf
CREATE TABLE SmplGrph (mygraph G)
APPEND BLANK
APPEND GENERAL MyGraph CLASS "MSGraph" DATA cTestdata
MODIFY GENERAL MyGraph NOMODIFY
@…SAY - BMP and OLE Objects, OLEBoundControl, OLEControl, Registration Database