30.07.2013 Views

T-FLEX Parametric CAD. Fundamentals. 2D Design

T-FLEX Parametric CAD. Fundamentals. 2D Design

T-FLEX Parametric CAD. Fundamentals. 2D Design

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.

Variables<br />

-23 % -5 = -3<br />

23 % -5 = 3<br />

-23 % 5 = -3<br />

The result of the operation member1 % member2 is the remainder of dividing member1 by member2.<br />

The value of member2 may not be zero. In the case member2 = 0, the error occurs, “Zero divide in<br />

line 1”.<br />

Besides the above-mentioned algebraic operations, logical (comparison) operations can be used in<br />

expressions. The result of a logical operation is the numerical value 1, if the relation defined by the operation<br />

is true, and 0 otherwise.<br />

Logical Operations<br />

Greater than ( > )<br />

Less than ( < )<br />

Greater than or equal ( >= )<br />

Less than or equal ( 45 && 56 < 34<br />

This example expresses the question: Is the number 23 greater than the number 45 and the number 56 less<br />

than the number 34? Obviously, the answer will be - no, therefore the value of this expression is zero.<br />

The expression !VAR_1 is the same as VAR_1 == 0<br />

Logical operations are usually used for comparing the value of a variable against a constant or a value of<br />

another variable. A shortcoming here is that only two values are possible as the result of evaluating a logical<br />

expression - 0 or 1.<br />

Another form of using logical operations is a conditional statement.<br />

A conditional statement has the following structure:<br />

condition ? value1 : value2<br />

Example:<br />

VAR_1 > 100 ? 1 : -1<br />

If the value of VAR_1 is greater than 100, then the statement will yield 1, otherwise it yields -1.<br />

One can use arbitrary expressions for the condition, value1 and value2.<br />

VAR_1 ? 1 : -1<br />

or, just the same thing,<br />

VAR_1 != 0 ? 1 : -1<br />

(VAR_1 != 0 && VAR_2 == 0) ? (VAR_3 + 1) : (VAR_4 -1)<br />

495

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

Saved successfully!

Ooh no, something went wrong!