NAME

if_op -- conditional execution of operands

PROTOTYPE

unitptr if_op( int iOperands, char *pcOps, unitptr uHost)

ARGUMENTS

int iOperands
nr of operand units in scope of if
char *pcOps
an arithmetic expression for the if-condition, 0=false, any other value=true
unitptr uHost
host unit

RETURN VALUE:

A pointer to the created unit or NULL in the case of an error.

INTERFACE OF CREATED UNIT:

X_in[iDim]:
(input field 0) up to 10 scalar float pins for x0-9
out0[1]:
(output field 0) float value of expression
out1[1]:
(output field 1) binary truth value
out2[1]:
(output field 2) complement of binary truth value

EXECUTION OF CREATED UNIT:

Evaluates the arithmetic expression given with pcOps sets output fields accordingly and executes operand units, if logical true (i.e., for nonzero result value). The arithmetic expression may use any of the usual arithmetic and boolean operators (.| and ||, & and && are both interpreted as OR and AND, respectively, equality needs always a "=="), numerical constants and any subset of the 10 variable names x0,x1..x9. If, say, the expression contains variables x1, x2 and x5, the created unit will have a scalar input field with six pins, each providing a value for one of the variables x0..x5 in that order (and with input at pins 0,3 and 4 ignored in the present example).

ADAPTATION:

The if-condition will be evaluated again on the adaptation pass, and if true, the operand units will be adapted (in the usual reverse adaptation order, that is, starting with the last operand).

EXAMPLES:


    (x0<1 && x0>2) || !((x1+2*x2)*x0 == 10 & x0!=0)

illustrates a legal expression, giving rise to a unit with 3 input pins for x0,x1,x2.

NOTE:

1. This unit offers a way to disable the execution of units that have no ctl-pin built in. 2. If iOperands=0, the unit can be used to compute an arithmetic expression. The result is available at out1. 3. The effect of an if-else can be obtained by connecting a second if-op unit with the single variable x0 to the negated out2 of the first if_op unit.

STATUS:

Alpha SEE ALSO prog_unit

FILE

/amnt/loge/users/nistaff02/nistaff/rhaschke/nst7/man/../o.linux//../nstsrc/nst_stdr.c