Statements define a sequence of operations executed during program execution. Statements may be elementary or composite. Elementary statements do not contain other statements. Elementary statements are: assignment statement, procedure calling, Break, Continue, Raise, Return and Dispose statements. Composite statements contain other statements. The platform also uses a ?: conditional statement.
$ Statement = { Empty | BreakStatement | ContinueStatement | DisposeStatement | RaiseStatement | ReturnStatement | ForStatement | ForEachStatement | IfStatement | RepeatStatement | CaseStatement | TryStatement | WhileStatement | WithStatement | Assignment | ProcedureCall }
$ Assignment = designator ":=" expression
An assignment statement replaces a variable, a field or an object property current value by a new value defined by the specified expression. A variable, a field or a property type have to be compatible with an expression type.
$ ProcedureCall = ( [ INHERITED ] designator ) “(“ [ActualParameters] “)”
A subprogram (procedure, function or method) call starts its execution. The subprogram call may also contain the list of actual parameters. Two schemes are available to compare formal and actual parameters: positional parameters and named parameters.
When positional parameters are used, actual parameters are formed as a list of parameters separated with commas. Each actual parameter is compared with a formal parameter, to which position it corresponds. In this case optional parameters, to which a default value may be referred, may be used. A list of actual parameters must contain mandatory parameters and may contain optional ones. Do not skip parameters. Thus, if a procedure has 8 (3 mandatory and 5 optional) parameters, and the 7th parameter will be defined, all the 6 previous parameters will be defined as well.
If named parameters are used, actual parameters are formed as a list of pairs: <formal parameter name>:=<actual parameter>. In this case, all mandatory and only the necessary actual parameters may be specified.
Consider the following procedure:
Sub SomeProc(p1, p2: Integer; p3: Integer = 0; p4: Integer = 1);
Begin
// list of statements
End Sub SomeProc;
p1, p2 – mandatory parameters.
p3, p4 – optional parameters.
The following procedure calls are correct:
SomeProc(1, 2, 3, 4);
SomeProc(1, 2, 3);
SomeProc(1, 2);
SomeProc(p1 := 1, p2 := 2, p4 := 4);
SomeProc(p2 := 2, p1 := 1);
The following calls are not correct:
SomeProc(1, 2, , ); SomeProc(1, 2, , 4); - empty omitted parameters are not allowed.
SomeProc(1); SomeProc(p1:=1, p3:=3); - not all mandatory parameters are specified.
Parameters may be passed into the program either by reference or by value. In this case, if a formal parameter is defined as a parameter by reference, an actual parameter has to be a variable or an object field. In case a formal parameter is defined as a parameter by value, an actual parameter must be an expression.
The INHERITED call may be used in a method body definition to call the specified method in a parent class.
The statements sequence defines the sequence of operations specified by the separate statements from the sequence. The statements are separated by the ; special character.
$ StatementSequence = statement [";"] | ({statement ";"} statement [";"])
$ Empty :
An empty statement is used when there are no statements to execute in a context where a statement is required. An empty string is used as the empty statement.