powered by CADENAS

Manual

Manual

7.8.11.  Attribute algorithms

[Note] Note

An example on attribute algorithms can be found in the "Training" catalog ($CADENAS/training/training.cip) under \v11_news\value_ranges\value_ranges_with_condition\din_1771.prj.

Dependencies between variables are expressed using so-called attribute algorithms. In the example (see following figure), you can see that the variable NENN is represented by the product of variables H, B and L.

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

Create attribute algorithms - Example

  1. Click on the button New.

  2. Under Name, enter the variable name NENN.

  3. Under Save location, choose the option Only in table or In geometry and table.

    (Using Save location "Only in geometry", no attribute algorithm can be used.)

  4. Under Status, select the option Attribute algorithm.

  5. Under Equation, open the enlarged input field with a click on the browse button ....

    Click on the button $VAR=.

    --> The variable name entered under Name is entered into the field as first part of the expression of the attribute algorithm.

  6. Enter the Assignment, which shall specify the Variable NENN.

    --> As NENN is a textual variable, the expression is NENN = '$H.x$B.x$L.'.

    "Attribute algorithm" dialog box

    "Attribute algorithm" dialog box

    [Note] Note

    Correct Syntax is important in this case:

    • Text variables

      Make sure your entries occur within the two apostrophes. In the format Dollar sign Name_of_variable Point (without empty spaces) 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.

    • Numeric variables

      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.

    Close the dialog with a click on OK.

    -> The entry is set under Equation.

  7. Click on Apply.

    -> The variable NENN is carried over into the listing of all project variables.

    -> The variable NENN is marked with the respective icon for Attribute algorithm.

Buttons for the creation of equation

(see Fig. „"Attribute algorithm" dialog box“)

  • $VAR=

    This button transfers the variable displayed under Name into the input field.

  • IF

    An algorithm constructed through an IF condition can look as follows:

    IF ( ) THEN 
       D3 = 
    ELSE 
       D3 = 
    ENDIF

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

    Behind THEN D3 =, enter the value which D3 has to accept if the condition is met.

    Behind ELSE D3 =, enter the value which D3 has to accept if the condition is not met. End the condition with ENDIF.

    Example with values:

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

  • ELSEIF

    If distinction of cases shall be made, use ELSEIF statements.

    Example with values

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

    [Note] Note

    ELSEIF cases have to be ended by an ELSE statement.

  • Several IF conditions set one after another within one Attribute algorithm variable.

    If you wanted to solve the same with one single IF condition with ELSEIF cases, this would require much more ELSEIFs.

    Structure of conditions with the help of an example:

    IF ( KG.EQ.'-')THEN
     NB1 = '$TNR. $TYP.-$KDM.-$HUB.-ZR-$WZ.'
    ELSE
     NB1 = '$TNR. $TYP.-$KDM.-$HUB.-ZR-$WZ.-$KG.'
    ENDIF
    IF ( ZAK.EQ.'-')THEN
     NB1 = '$NB1.'
    ELSE
     NB1 = '$NB1.-$ZAK.'
    ENDIF
    IF( YSR.EQ.'1'.AND.SIE.EQ.'-')THEN
     NB1 = '$NB1. ZUB-C'
    ELSEIF( YSR.EQ.'1'.AND.SIE.EQ.'1')THEN
     NB1 = '$NB1. ZUB-CL'
    ELSEIF( YSR.EQ.'2'.AND.SIE.EQ.'-')THEN
     NB1 = '$NB1. ZUB-$YSR.C'
    ELSEIF( YSR.EQ.'2'.AND.SIE.EQ.'1')THEN
     NB1 = '$NB1. ZUB-$YSR.CL'
    ELSEIF( YSR.EQ.'-'.AND.SIE.EQ.'1')THEN
     NB1 = '$NB1. ZUB-L'
    ELSE
     NB1 = '$NB1.'
    ENDIF                                            

    In first IF NB1 is initialized.
    
    
    
                                        
    In second IF something is attached to NB1.
    
    
    
                                         
    In third IF something is attached again.
    
    
    
    
    
    
    
    
    
    
    
                                             

    Important notes:

    • The first IF condition has to contain an ELSE alternative, in order for the variable to be initialized. All other IF conditions may contain ELSE alternatives optionally.

      Correct:

      IF (OPZ1.EQ.'-' )THEN
       LINAALG = '$IDNR./$CX1./$VL./$MOTX./$OM1./$COEL./$DA./$AP1./$AA1.'
      ELSE
       LINAALG = '$IDNR./$CX1./$VL./$MOTX./$OM1./$COEL./$DA./$AP1./$AA1./$OPZ1.'
      ENDIF
      IF (OPZ2.EQ.'-' )THEN
       LINAALG = '$LINAALG./'
      ELSE
       LINAALG = '$LINAALG./$OPZ2.'
      ENDIF...

      Incorrect:

      IF (OPZ1.NE.'-' )THEN
       LINAALG = '$IDNR./$CX1./$VL./$MOTX./$OM1./$COEL./$DA./$AP1./$AA1./$OPZ1.'
      ENDIF
      IF (OPZ2.NE.'-' )THEN
       LINAALG = '$LINAALG./$OPZ2.'
      ENDIF...

      Also correct: If there is a simple statement at the first position, an "ELSE" can be omitted at all, since the statement will always initialize the variable.

      CNSTYPECODE = '$MODEL.$W.-$ST.-$THETA.-$TYPE.-$SPRING.'
      IF(K.EQ.1)THEN
       CNSTYPECODE = '$CNSTYPECODE.-K'
      ENDIF
      IF(FK.EQ.1)THEN
       CNSTYPECODE = '$CNSTYPECODE.-FK'
      ENDIF
      IF(N.EQ.1)THEN
       CNSTYPECODE = '$CNSTYPECODE.-N'
      ENDIF

    • The first condition, which is always calculated, has to prevent an endless loop. Following "if...endif" always call the first condition and attach an additional value.

      So in the first condition do not use the variable of assignment for the ELSE case.

      Correct:

      IF (OPZ1.EQ.'-' )THEN
       LINAALG = '$IDNR./$CX1./$VL./$MOTX./$OM1./$COEL./$DA./$AP1./$AA1.'
      ELSE
       LINAALG = '$IDNR./$CX1./$VL./$MOTX./$OM1./$COEL./$DA./$AP1./$AA1./$OPZ1.'
      ENDIF
      IF (OPZ2.EQ.'-' )THEN
       LINAALG = '$LINAALG./'
      ELSE
       LINAALG = '$LINAALG./$OPZ2.'
      ENDIF...

      Incorrect: (difference in red)

      IF (OPZ1.EQ.'-' )THEN
       LINAALG = '$IDNR./$CX1./$VL./$MOTX./$OM1./$COEL./$DA./$AP1./$AA1.'
      ELSE
       LINAALG = '$LINAALG./$OPZ1.'
      ENDIF
      IF (OPZ2.EQ.'-' )THEN
       LINAALG = '$LINAALG./'
      ELSE
       LINAALG = '$LINAALG./$OPZ2.'
      ENDIF...

Error avoidance

Make sure that attribute algorithms do not contain recursions.

For a quick testing call the function Show variable dependencies in the table docking window. Unilateral dependency is Ok. This is signalized by a single arrow. Recursive dependencies are errors. These are signalized by a left right arrow. Errors are displayed both in the message docking window and later when testing in the dialog box QA check.

The following exemplary figure shows simple dependency between A and B.

Equation: A = B

Simple dependency -> OK

Simple dependency -> OK

The following exemplary figure shows recursive dependency. The Variable Manager shows A=B and B=A. In the dialog box Variable dependencies you can see a left right arrow between A and B. In the 3D History a red cross is shown at affected elements, the dialog box Notifications reflects the error and the 3D view does not show a model.

Recursive dependency -> Error

Recursive dependency -> Error

In the dialog box QA check an error message appears.

QA check with error "Recursion in algorithm"

QA check with error "Recursion in algorithm"