The callwithin statement allows a procedure to call a mini-procedure within a separate procedure within the current database as a subroutine.
This statement has three parameters:
procedure – is the name of the procedure to call. If the mini-procedure name does not have any spaces or punctuation, no quotes are required. You can also use a formula to calculate the procedure name “on the fly.”
label – identifies the beginning of the mini-procedure. (The end of the mini-procedure is defined by a rtn or return statement or the end of the main procedure). A label is a unique series of letters and numbers that identifies a location within the procedure. The label may not contain any spaces or punctuation except for ., _ and %, and must always end with a colon. The colon is not actually part of the label, it simply identifies the series of letters and numbers as a label instead of a field or variable..
parameters – is a list of parameters to be passed to the subroutine. This list is optional, you don’t have to pass any parameters if you don’t need to. See parameter( and setparameter for more information on accessing parameters within a subroutine.
This example shows how three different mini-procedures within the Calculate procedure can be called.
callwithin Calculate,Total callwithin Calculate,Tax callwithin Calculate,Shipping
In the example above the procedure name and label are fixed, but you can use a formula to calculate either of these, as shown here:
callwithin UserInterface,replace(info("trigger")," ","")
This example assumes that the UserInterface procedure includes labels something like this:
Button.Ok: ... ... ... return Button.Cancel: ... ... ... return Button.NewUser ... ... ... return
If the specified label does not exist, an error occurs. You can check the labels in advance with the getprocedureoption( function.
local userTrigger userTrigger = replace(info("trigger")," ","") if arraycontains(getprocedureoption("","UserInterface","LABELS"),userTrigger,cr()) callwithin UserInterface,userTrigger else returnerror userTrigger+" not implemented yet!" endif
When you call a subroutine you can supply one or more parameters to be passed to the subroutine (parameters must be separated by a comma). When using the callwithin statement the parameters are listed after the label name, like this:
callwithin procedure,label,parameter1,parameter2,parameter3, ... parameterN
See the call statement for more information about accessing and modifying parameters.
|10.0||New||New in this version.|