09.12.2012 Views

Basic Characteristics RAPID

Basic Characteristics RAPID

Basic Characteristics RAPID

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

TEST Depending on the value of an expression ...<br />

Example<br />

Arguments<br />

TEST is used when different instructions are to be executed depending on the value of<br />

an expression or data.<br />

If there are not too many alternatives, the IF..ELSE instruction can also be used.<br />

TEST reg1<br />

CASE 1,2,3 :<br />

routine1;<br />

CASE 4 :<br />

routine2;<br />

DEFAULT :<br />

TPWrite "Illegal choice";<br />

Stop;<br />

ENDTEST<br />

Different instructions are executed depending on the value of reg1. If the value<br />

is 1-3 routine1 is executed. If the value is 4, routine2 is executed. Otherwise, an<br />

error message is printed and execution stops.<br />

TEST Test data {CASE Test value {, Test value} : ...}<br />

[ DEFAULT: ...] ENDTEST<br />

Test data Data type: All<br />

The data or expression with which the test value will be compared.<br />

Test value Data type: Same as test data<br />

Program execution<br />

The value which the test data must have for the associated instructions to be executed.<br />

The test data is compared with the test values in the first CASE condition. If the comparison<br />

is true, the associated instructions are executed. After that, program execution<br />

continues with the instruction following ENDTEST.<br />

If the first CASE condition is not satisfied, other CASE conditions are tested, and so<br />

on. If none of the conditions are satisfied, the instructions associated with DEFAULT<br />

are executed (if this is present).<br />

<strong>RAPID</strong> Reference Manual 8-TEST-1

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

Saved successfully!

Ooh no, something went wrong!