18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

<strong>SIMSCRIPT</strong> <strong>II.5</strong> <strong>Programming</strong> <strong>Language</strong><br />

1. I equals J is true or false depending on the values I, J<br />

2. I equals Q is always false<br />

3. M + N is positive is always true<br />

4. M + T is positive is true or false depending on the values M, T<br />

5. I > 0 and J > 0 is always true<br />

6. I > 0 or R > 0 is always true<br />

7. I eq J and Z eq 0 is true if I equals J, and false otherwise<br />

8. I eq J or Z eq 0 is always true<br />

9. I = J and K > N and R = S is true if all three conditions are true, and<br />

false otherwise; it is evaluated as ((I =<br />

J) and (K > N) and (R = S))<br />

10. I = J or K > N or R = S is true if any one of the three conditions<br />

is true; it is false only if all are false<br />

11. I = J and K > N or R = S is true if either of the two conditions<br />

12. Z is zero and (I < 0 or S < 0) and Q = T is true if Q = T<br />

13. Z is zero and (I > 0 or S < 0) and Q = T is true if Q = T<br />

around the or is true; it is evaluated as<br />

(I = J and K > N) or (R = S)<br />

14. J< K and (I = Q or S < 0) and J + K < I is true if J < K and J + K < I<br />

When a statement containing a compound logical expression is executed, it does not always follow<br />

that all logical conditions in the statement are examined. For example, in the segment:<br />

if X > Y**2 and COUNT > N<br />

add ...<br />

always<br />

both logical expressions have to be true for the add statement to be executed. If the first logical<br />

expression (X > Y**2) is false, there is no need to evaluate the second (COUNT > N), as the compound<br />

logical expression X > Y**2 and COUNT > N can never be true regardless of the values of COUNT<br />

and N. In normal circumstances, the fact that all the parts of a compound logical expression may<br />

not be evaluated each time will cause no difficulty.<br />

It should be noted that compound logical expressions formed using the logical operator and may<br />

be written in an alternative way. Using e to represent an arithmetic expression and R to represent a<br />

relational operator, such compound logical expressions may be written as:<br />

Form<br />

e R e<br />

e R e R e<br />

Example<br />

1 < X<br />

1 < X < N<br />

18

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

Saved successfully!

Ooh no, something went wrong!