Equinox Online Help - Language Reference - A to Z

Home

Procedure ... End Procedure

Applies to
Syntax[Public ]Procedure LabelName [parameters] [Subtable TableName]
local variable declarations
statements
[Return]
End Procedure
Action[Statement] Declares a procedure.
ScopeLocal procedure declarations must be made in the Local Procedures method. If a module does not have a Local Procedures method then you can use any other method, but the declaration must be outside of any block structure (Block, Subtable etc). Public procedures must be declared in a public procedure library, accessed through the Public Procedure screen.
Notes

This structure effectively allows you to define your own language statements.

You may use the Public keyword to declare a public procedure. Note that you can only do this in the Public Procedures screen.

LabelName is the procedure's name (which you use to call it). Parameters are special variables, local to the procedure. They receive values (as arguments) when the procedure is called. You define the parameters using variable declarations, separated by commas. You may include upto sixteen parameters.

TableName allows you to define a home table for the procedure. You should only include it if the procedure is public, or will be called from inside a subtable block. In that case, use the same table name. If the procedure needs to be called from more than one subtable block, or a subtable and the main block, use the keyword NoTable instead of Subtable TableName. If you use NoTable, you must not use field names directly in the procedure.

If you want to declare variables local to the procedure, you may do so before the procedures statements. Also note that you can exit the procedure at any point using the Return statement. You use the following syntax to call a procedure:

LabelName [arguments]

LabelName is the name you assigned to the procedure when you declared it. The arguments are values which pass to the procedure's parameters (there must be one for each parameter). You can use field values, workarea values, variables, constants, or expressions as arguments. Notice that changes made to a parameter are also made in the corresponding argument (if it is a field value, workarea, or variable). This is because arguments are not real variables, but pointers to the values passed to them.

Note that you can call procedures recursively, ie a procedure can call itself.

CategoryDeclarations
See Also Date, Define, Logical, Memo, Number, Public, Radio, String, Time
Example

The following example uses a procedure to display a standard message.

if AssetNumber <> 0 then
Exit Method
else
TestIfEmpty | Procedure call
end if

The TestIfEmpty procedure is stored in the local procedures method.

procedure TestIfEmpty
Alert "Please supply a value"
end procedure | TestIfEmpty

The next example is similar, but passes a parameter to the procedure.

if AssetNumber <> 0 then
Exit Method
else
TestIfEmpty "asset Number"
end if

The procedure is now defined as follows:

procedure TestIfEmpty String AMessage
Alert "Please supply a value For" & AMessage
end procedure | TestIfEmpty