powered by CADENAS

Manual

Manual

11.5.2.7.  Attribute algorithms

[Note] Note

Some examples about attribute algorithms can be found in the training catalog ($CADENAS/training/training.cip) under /parteditor/....

Dependences between variables are expressed using so-called attribute algorithms. In the example (see illustration), you can see that the NENN variable is represented by the product of variables DG and L.

Set attribute algorithm - example

  1. Before a variable can be defined for the algorithm, status Attribute algorithm must be assigned to it in Variable Manager window.

  1. --> The Attribute algorithms window lists all related Variables. Choose the variable to be edited.

  1. Click on button $VAR=

    --> The Variable is entered as the first expression element of the attribute algorithm’ in the adjacent field.

  1. Set the Assignment which should define the Variable NENN.

    --> In this case NENN = $ DG . x $ L . .

[Note] Note

Correct syntax is important in this case.

For text variables: Make sure your entries occur within the two apostrophes . In the dollar sign format Name of variable Point variables can be used as place holders in the algorithm. Combinations with other text or arithmetic operators and connections via IF and ELSEIF functions (see explanation further down) are possible.

In the case of numeric variables: ...no apostrophes are required. A numeric variable can be assigned a fixed numerical value and/or a calculation which, in turn, contains variables.

  • $VAR=

    This button transfers the currently selected variable to the field.

    The same does the function "VAR=" in the context menu.

  • IF

    An algorithm constructed through an IF condition can look as follows (see fig.):

    Enter your condition (e.g. (L1.EQ.10) between the brackets ().

    Enter the value which D3 is to assume if the condition is met after THEN D3 =.

    The value for D3 if the condition is not met is located after ELSE D3 =. You include the condition with ENDIF.

    Example with values: IF (L1.EQ.10) THEN

    D3 = 20

    ELSE

    D3 = 30

    ENDIF

  • ELSEIF

    If more than one condition is to be checked, you can work with ELSEIF statements.

    Example IF (L1.LT.10) THEN

    D3 = 1

    ELSEIF (L1.LT.20) THEN

    D3 = 2

    ENDIF

The following conditions are possible:

.EQ.

eq ual

.GT.

g reater t han

.GE.

greater than or e qual

.LT.

l ess t han

.LE.

less than or e qual

.AND.

(both conditions - to the right and left of .AND. - must be met)

.OR.

(one of the two conditions - to the right or left of .OR. - must be met)

.NE.

n ot e qual

The following mathematical (textual) functions may be used:

+, -, *, /

Basic arithmetic operations

**

Exponentiation

VAR =  
IF (....) ...

IF () THEN
  VAR = 
ELSE
  VAr = 
ENDIF

ELSEIF (....) ...

IF () THEN
  VAR = 
ELSE

number = ABS (number)

Absolute value:

Example:

|-3.4| = 3.4

number = AINT (number)

Truncate non-integral number range

Example:

AINT(3.1) = 3
AINT(3.9) = 3
AINT(-3.9) = -3

number = ANINT (number)

Next real integer (rounding)

Example:

ANINT(3.1) = 3
ANINT(3.9) = 4
ANINT(-3.9) = -4

number = SIN (number)

Sine

number = SINH (number)

Hyperbolic sine

number = COS (number)

Cosine

number = COSH (number)

Hyperbolic cosine

number = TAN(number)

Tangent

number = TANH(number)

Cosine tangent

number = ASIN (number)

Arc sine

number = ACOS (number)

Arc cosine

number = ATAN (number)

Arc tangent

number = ATAN2 (number,number)

Arc tangent with two arguments

The result is returned in degree.

number = SQRT (number)

Square route

number = DIM (number,number)

Positive difference:

As long as the first number is bigger than the second, the calculation is: number 1 - number 2; otherwise the result is 0.

Example:

DIM(8,4) = 4
DIN(4,8) = 0

number = EXP (number)

Exponential function

number = INT (number)

Cutting the decimal places

Example:

INT(4,9) = 4

number = NINT (number)

Rounding

Example:

NINT(4.9) = 5
NINT(4.5) = 5
NINT(4.1) = 4

number = LOG (number)

Natural logarithm

number = LOG10 (number)

Logarithm base 10

number = MAX (...)

MAX (A1, A2, A3,…) 

Maximum value of parameters

number = MIN (...)

MAX (A1, A2, A3,…) 

Minimum value of parameters

number = MOD (number,number)

Remainder calculation:

A – INT (A/P)*P

Example

MOD(11,4) = 3
11 - (INT(11/4)*4) = 11 - 2*4 = 3
11 / 4 == 2 Rest 3

number = SIGN (number,number)

Sign transfer: |A| signum (B)

SIGN(A,B) means that the return of the value of A is given with the prefix of B.

Example:

SIGN(10,1)   =  10
SIGN(10,-1)  = -10

SIGN(-10,1)  =  10
SIGN(-10,-1) = -10

text = TRANSLATE ('text')

text = TRANSLATE ($VARIABLENNAME.)

text = $VARIABLENNAME(SRC=VALDESC).

See Section 11.5.2.7.1, “Translation functions”.

number = ATOF ('text')

Changes text to number:

Example:

ATOF ('3.2') -> 3.2

LEN ('text')

LEN (Variable)

Length of text:

LEN('abcd')  = 4
LEN(VAR)  = Länge des Textes in der Variable VAR
text = SUBSTR (text,number,number)

Section from text

The first parameter is the text, the second indicates at which symbol the extract begins, and the third parameter indicates the length of the extract.

Example:

SUBSTR('Hallo Welt',1,5) -> Hallo
SUBSTR('Hallo Welt',7,4) -> Welt

text = GETTHREADTEXT (number,text,text,number)

Used with threads:

Using the following expression you can generate different output.

Example:

NAME  =  GETTHREADTEXT(D,'DIN 13','',P,'NAME')

A detailed description can be found under Section 10.5.4.3.11.1.1.2, “Fine thread - variants ”.

number = GETTHREADVALUE (number,text,text,number)

Compare the preceding function

GETTHREADTEXT gets a text from the table and GETTHREADVALUE a DOUBLE value.

These functions may occur in conditions ( IF (L1.LT.SQRT(25)) THEN ... ) or in allocations of numeric variables ( D3=LOGL1 or A=(B+5)*3-10/2 or C=SQRT(A**2+B**2) ).

[Note] Note

In the case of tangent functions, the angle values are in degrees.

The following functions cannot be used: FORMATSTR, FORMATVAL, KFIX