powered by CADENAS

Manual

Manual

7.8.11.1. Mathematical functions (Attribute algorithm)

[Note] Note

Functions may occur in conditions and allocations of numerical variables.

Example condition:

IF (L1.LT.SQRT(25)) THEN ...

Examples Allocation of numerical variables:

D3=LOGL1

A=(B+5)*3-10/2

C=SQRT(A**2+B**2)

Conditions

IF () THEN
  VAR = 
ELSE
  VAR = 
ENDIF

Commands:

  • IF (....): Between the brackets (), enter the condition (e.g. "<Variable>.EQ.10").

  • THEN: Behind THEN <Variable> =, enter the value which the variable shall accept if the condition is fulfilled.

  • ELSE ...: Behind ELSE <Variable> =, enter the value which the variable shall accept if the condition is not fulfilled.

  • ELSEIF (....): Between IF and ELSE, any number of distinction of cases can be added.

    [Note] Note

    ELSEIF loops have to be ended by an ELSE.

  • ENDIF: End of condition.

Examples with values:

IF (L1.EQ.10) THEN
D3 = 20
ELSE
D3 = 30
ENDIF

IF (L1.EQ.10) THEN 
D3 = 10 
ELSEIF (L1.EQ.20) THEN 
D3 = 20 
ELSE
D3 = 30
ENDIF 

Logical operators:
  • Comparison

    .EQ.

    equal

    .GT.

    greater than

    .GE.

    greater than or equal

    .LT.

    less than

    .LE.

    less than or equal

  • Linking

    .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

  • Boolean values

    .TRUE.

    An expression can be equal to "true".

    --- .EQ..TRUE. ---

    .FALSE.

    An expression can be equal to "false".

    --- .EQ..FALSE. ---

Operator for concatenation of strings

The operator // allows to concatenate variable values with text (or other variable values).

[Note] Note

Variables have to be stated without $..

Examples:

TYPE=‘new‘//TYPE

CONC = ABC//'0'//PQR//XYZ

In PARTdesigner, variables can used inside a string.

Examples:

C= 'Test --- $A.-$B.'

NENN = '$H.x$B.x$L.'

This syntax can NOT be used for ERP mapping, so that especially here, using the // operator is very helpful.

Basic arithmetic operations

+, -, *, /

Basic arithmetic operations

**

Exponentiation

Mathematical functions

number = ABS (number)

Absolute value:

Example:

|-3.4| = 3.4

number = INT (number)

number = AINT (number)

INT converts the number to "Integer".

AINT truncates the decimal places.

The result from INT and AINT is the same as long as the number is in the range of integer, meaning between -2^31 and 2^31.

Convert to "Integer" / Truncate decimal places

Example:

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

number = ANINT (number)

number = NINT (number)

The two functions are identical.

Next real integer (rounding)

Example:

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

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
DIM(4,8) = 0

number = SQRT (number)

Square root

number = EXP (number)

Exponential function

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

Angular functions

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

Inverse functions to above mentioned:

number = ASIN (number)

Arc sine

number = ACOS (number)

Arc cosine

number = ATAN (number)

Arc tangent

number = ATAN2 (number,number)

Arc tangent with two arguments

ATAN2 is an enhancement to ATAN and like that an inverse function of the angular function Tangent.

It takes two real numbers as argument, in contrary to the normal Arc Tangent, which only takes one number. In this way it has enough information to be able to return values in the full range of 360 degrees (meaning four quadrants) and is not restricted to two quadrants (as the normal Arc Tangent).

atan2(y,x) returns the angle θ between the ray to the point (x,y) and the positive x-axis, confined to (-Pi,Pi].

The result is returned in degree.

[Note] Note

At angular functions the entry in brackets mirrors the degree value.

Text-related 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)  = Length of text in 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

[Note] Note

The following functions can not be used: FORMATSTR, FORMATVAL, KFIX

Thread functions

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 7.9.3.11.1.1.2, “Different pitches and derived automatic calculations for e.g. Row Label and Core diameter ”.

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

Compare the preceding function

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

Translation functions

text = TRANSLATE ('text')

TRANSLATE translates a text into the current language.

Also see Section 7.8.11.2, “ Translation functions” -> Example 1

text = TRANSLATE (VARIABLENNAME)

However, if in Row Label, Data sheet, 2D derivation, etc., the visible translated value shall be used, you can use the function "TRANSLATE(VARIABLENNAME)".

Also see Section 7.8.11.2, “ Translation functions” -> Example 2 and 3

text = $VARIABLENNAME(SRC=VALDESC).

Also see Section 7.8.11.2, “ Translation functions” -> Example 4