7.8.12.2. Syntax - Buttons for creating the formula

If you use the $VAR= | IF | ELSEIF buttons, you can be sure that the correct syntax is used when creating the formula.

"Feature algorithm [Attribute algorithm]" dialog box

"Feature algorithm [Attribute algorithm]" dialog box

[Note]Note

Use Check to check your entries in between or at the end.

The error message appears directly below the algorithm (also in the log window). As soon as the Check button is clicked, an error description with row and column information appears. To hide the Error dialog area, click on the red X button.

If there are no more errors, the corresponding message appears.

  • $VAR=

    This button only transfers the variable displayed under Name to the input field.

  • IF

    An algorithm built using an IF condition can look like this:

    IF ( ) THEN 
       D3 = 
    ELSE 
       D3 = 
    ENDIF

    Enter your condition between the brackets () (e.g. "L1.EQ.10"). In this example, "D3" is the variable selected in the variable list.

    After THEN D3 = enter the value that D3 should assume if the condition is met .

    After ELSE D3 = is the value for D3 if the condition is not fulfilled . End the condition with ENDIF .

    Example with values:

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

  • ELSEIF

    -> The following is generated:

    ELSEIF ( ) THEN
     <selektierte Variable> = 

    If case distinctions are to be made, ELSEIF statements can be used.

    [Note]Note

    ELSEIF case distinctions must be concluded with an ELSE at the end.

    So before you click, place the cursor in the correct position before the ELSE command.

    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 

  • Several IF conditions can also be connected in series within a feature algorithm variable [Attribute algorithm].

    The use of a single IF condition with ELSEIF case distinctions would often lead to much more complex solutions with many more ELSEIFs.

    Structure of the conditions using 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                                            

    Im  ersten IF wird NB1 initialisiert.
    
    
    
                                        
    Im zweiten IF wird an NB1 etwas drangehängt.
    
    
    
                                         
    Im dritten IF wird nochmal etwas drangehängt.
    
    
    
    
    
    
    
    
    
    
    
                                             

    Important notes:

    • The first IF condition must contain an ELSE alternative to ensure that the variables are initialized. The remaining IF conditions can optionally contain ELSE alternatives.

      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...

      Not correct: (The first IF does not contain an ELSE)

      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 the first statement is a simple statement without a condition, an "ELSE" can be omitted completely, as the statement always initializes 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, must prevent an infinite loop. Further "if...endif" always call the first condition and add an additional value.

      Therefore, do not use the variable of the assignment in the first condition for the ELSE case differentiation.

      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...

      Not correct: (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...