09.12.2012 Views

Basic Characteristics RAPID

Basic Characteristics RAPID

Basic Characteristics RAPID

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Basic</strong> <strong>Characteristics</strong> <strong>RAPID</strong> Expressions<br />

7.5 Using aggregates in expressions<br />

An aggregate is used for record or array values.<br />

Example: pos := [x, y, 2*x]; pos record aggregate<br />

posarr := [[0, 0, 100], [0,0,z]]; pos array aggregate<br />

It must be possible to determine the data type of an aggregate the context. The data type<br />

of each aggregate member must be equal to the type of the corresponding member of<br />

the determined type.<br />

Example VAR pos pl;<br />

p1 :=[1, -100, 12]; aggregate type pos - determined<br />

by p1<br />

IF [1, -100, 12] = [a,b,b,] THEN illegal since the data type of neither<br />

of the aggregates can be<br />

determined by the context.<br />

7.6 Using function calls in expressions<br />

A function call initiates the evaluation of a specific function and receives the value<br />

returned by the function.<br />

Example: Sin(angle)<br />

The arguments of a function call are used to transfer data to (and possibly from) the<br />

called function. The data type of an argument must be equal to the type of the corresponding<br />

parameter of the function. Optional arguments may be omitted but the order<br />

of the (present) arguments must be the same as the order of the formal parameters. In<br />

addition, two or more optional arguments may be declared to exclude each other, in<br />

which case, only one of them may be present in the argument list.<br />

A required (compulsory) argument is separated from the preceding argument by a<br />

comma “,”. The formal parameter name may be included or omitted.<br />

Example: Polar(3.937, 0.785398) two required arguments<br />

Polar(Dist:=3.937, Angle:=0.785398)... using names<br />

An optional argument must be preceded by a backslash “\” and the formal parameter<br />

name. A switch type argument is somewhat special; it may not include any argument<br />

expression. Instead, such an argument can only be either "present" or "not present".<br />

Example: Cosine(45) one required argument<br />

Cosine(0.785398\Rad) ... and one switch<br />

Dist(p2) one required argument<br />

Dist(\distance:=pos1, p2) ... and one optional<br />

Conditional arguments are used to support smooth propagation of optional arguments<br />

through chains of routine calls. A conditional argument is considered to be “present”<br />

if the specified optional parameter (of the calling function) is present, otherwise it is<br />

<strong>RAPID</strong> Reference Manual 5-29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!