Append Procedures, Copy Procedures

These commands let you move code between the stored procedures of a database and text files. APPEND PROCEDURES adds the contents of a file to the current database's stored procedures, while COPY PROCEDURES lets you save the stored procedures in a file.

Usage

APPEND PROCEDURES FROM FileName
     [ AS nCodePage ]
     [ OVERWRITE ]
COPY PROCEDURES TO FileName
     [ AS nCodePage ]
     [ ADDITIVE ]
As with other APPEND/COPY pairs, the default for APPEND is additive, while the default for COPY is destructive. Hence, APPEND PROCEDURES has an optional OVERWRITE keyword that lets you replace what's already there, while COPY PROCEDURES has an optional ADDITIVE clause that lets you keep what's already there and add to it.The AS codepage in each command specifies a codepage for the text file. On the way in, FoxPro converts from that codepage to the database's codepage. On the way out, the reverse happens.COPY PROCEDURES assumes an extension of TXT (rather than PRG, as we'd expect). APPEND PROCEDURES, on the other hand, is even less sensible—if you don't give it an extension, it assumes you don't want one. So APPEND PROCEDURES FROM MyProc doesn't look for MyProc.PRG or even MyProc.TXT, but just plain old MyProc. The upshot of all this is that you should always include the extension with these commands.

In VFP 3, when the stored procedures already contain RI code generated by the RI builder, there's no final return. When you APPEND PROCEDURES, the first line of the text file ends up on the same line as the final RI-generated line. Leaving things that way is guaranteed to cause trouble down the road, so you'll want to make sure the extra return gets in there somehow, whether by manually inserting it or by making sure the first line of the appended file contains just a return. In VFP 5 and later, RI code does have a final return, so this is a non-issue.


APPEND PROCEDURES only works when the full VFP environment is available, since it needs to be able to compile the procedures. Trying to use it in a runtime environment results in a "feature is not available" error. The reason for this is that VFP needs to be able to compile the procedures. While that was a reasonable limitation in versions prior to VFP 6 Service Pack 3, VFP has been able to compile files in a runtime environment since that release. We suspect this is one of those things the Fox team just forgot to change.


In VFP 7, if the database has database events turned on, the BeforeAppendProc and AfterAppendProc events fire for APPEND PROCEDURES, and the BeforeCopyProc and AfterCopyProc events fire for COPY PROCEDURES.

Example

OPEN DATA MyTestData
APPEND PROCEDURES FROM GetId.PRG
COPY PROCEDURES TO TestProc.PRG

See Also

AfterAppendProc, AfterCopyProc, BeforeAppendProc, BeforeCopyProc, Display Procedures, Modify Procedure


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .