Method (Reserved Word)
The method reserved word allows you to create a named subroutine within an EasyLanguage document that consists of a sequence of statements. Methods can have input parameters, but methods are not required to have input parameters. Methods can return a value or an object to the caller, but methods do not have to return anything.
Remarks
Methods are local to the EasyLanguage document. Variables declared within a method are usable only within the method. The EasyLanguage statements within a method are only executed when the method is called. A method can be called from anywhere within the EasyLanguage document, or can be called when an event (e.g., a button click) occurs.
Syntax sample
method double myMethod(int Param1)
var: double myVar;
begin
{EasyLanguage statements}
return myVar;
end;
The data type of the method's return value appears between the method reserved word and the name you give to the method. A return statement in the method is used to return a value that is of the data type specified in the method's declaration statement. If a method is not intended to return anything then the method will not include a return statement. When a method does not return anything, the word void is used in the method's declaration as the return type (see example below).
Methods can accept optional input parameters within the parenthesis following the method's name. The data type of the inputs must be specified in front of each input's name.
Local variables (variables used only within the method) can be declared after the method declaration statement, just before the begin ... end block that encloses the body of the method.
The variable declaration rules in a local method are slightly different than for a variable declaration in the main body of an EasyLanguage document (see above). In a method, the data type is required, but no initial value is specified in parentheses after the variable's name.
Example
The following method reads and displays account information from the AccountsProvider1 object that was created using the AccountsProvider class. When ShowInformation(0) is called, the first plot displays the Account ID of the first Account in the AccountProvider's Account collection (acctIndex is 0). The second plot displays the Real Time Net Worth value for the same account. Since this method does not return a value its return type is void.
method void ShowInformation(int acctIndex)
begin
if (AccountsProvider1.Count > 0) then
begin
Plot1(AccountsProvider1.Account[acctIndex].AccountID, "Account ID");
Plot2(AccountsProvider1.Account[acctIndex].RTAccountNetWorth, "RT Net Worth");
end;
end;
See Also
in (reserved word)
out (reserved word)