importprocedure
ARCHIVE
,
OPTION
,
VALUE

The importprocedure statement imports a procedure into a database.


Parameters

This statement has three parameters:

archive – is a binary archive containing the procedure to import. This archive must have been originally created with the exportprocedure( function.

option – one or more options that modify the import. See below for descriptions of each option. The option can be specified in either upper or lower case.

value – is the option value (see below).


Description

This statement imports a procedure into a database. The procedure must have been previously saved with the exportprocedure( function. This example copies the procedure Display Message from the current database into the Checkbook database.

local transferData
transferData=exportprocedure("Display Message")
opendatabase "Checkbook"
importprocedure transferData

If the Checkbook database already contained a Display Message procedure, it will be updated. If it did not contain a Display Message procedure, it will be added.

Note: In addition to the archive parameter, you can also specify one or more option/value pairs that modify the import operation, like this:

importprocedure procedureArchive,option1,value1,option2,value2,option3,value3

NAME

This option specifies the name of the imported procedure. This example makes a copy of the Do Something procedure.

local transferData,procedureName
procedureName = "Do Something"
transferData=exportprocedure(procedureName)
importprocedure transferData,"Name",procedureName+" Copy"

If there is no name option, the original name the procedure had when the exportprocedure( function was used will be used.

DATABASE

This option allows you to specify the database the procedure will be imported into. You can import the procedure into any open database. If this option is omitted, the procedure will be imported into the current database.

importprocedure transferData,"Database",targetDB

INSERTBEFORE

This option allows you to specify the location of the imported procedure. The imported procedure will be imported in front of the specified procedure. This example makes a copy of the Calculate Total and inserts the copy above the Calculate Total procedure, renaming it Calculate SubTotal.

local transferData,procedureName
procedureName = "Calculate Total"
transferData=exportprocedure(procedureName)
importprocedure transferData,"Name","Calculate SubTotal","InsertBefore","Calculate Total"

If there is no insertbefore option, the imported procedure will be added at the end of the current list of procedures (unless it already exists, in which case it will be updated).

UPDATE

If the procedure to be imported already exists, the importprocedure statement updates the existing procedure rather than adding a duplicate. If the update option is false, the statement will NOT update the existing procedure (instead an error message will be generated.). This example copies the procedure Display Message from the current database into the Checkbook database, however, if the Display Message procedure already exists in the Checkbook database, the program will stop with an error.

local transferData
transferData=exportprocedure("Display Message")
opendatabase "Checkbook"
importprocedure transferData,"update","false"

CREATE

If the procedure to be imported does not already exist, the importprocedure statement will create it. However, if the create option is false, the statement will NOT create a new procedure in the database (instead an error message will be generated.). This example copies the procedure Display Message from the current database into the Checkbook database, however, if the Display Message procedure does not already exist in the Checkbook database, the program will stop with an error. (If it does exist, it will be updated.)

local transferData
transferData=exportprocedure("Display Message")
opendatabase "Checkbook"
importprocedure transferData,"create","false"

See Also


History

VersionStatusNotes
10.0NewNew in this version.