EasyLanguage Reserved Words & Functions
The method reserved word allows you to create a named subroutine within an EasyLanguage document that consists of a sequence of statements to perform an action, a set of input parameters to customize those actions, and possibly a return value.
Methods are local to the EasyLanguage document and local variables declared within a method are active only within the scope of that 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.
method double myMethod(int Param1)
var: double myVar;
begin
{EasyLanguage statements}
return myVar
end;
The data type of the method always 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 the same data type as the method. If a method does not include a return statement, the word void is used.
Methods can accept optional input parameters within the parenthesis following the method name. The data type of the inputs must be specified in front of each input parameter name.
Local variables that are only used within a method are declared after the method declaration statement and the begin...end statements containing 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 and no initial value is allowed after the variables name.
The following method reads and displays account information from the AccountsProvider1 object that was created using the Accounts Provider component. When ShowInformation(0) is called, the first plot displays the Account ID of the first Account in the provider collection (acctIndex is 0) and the second plot displays the Real Time Net Worth value for the same account. Since this method does not return a value it's 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;