String functions

Application

The string functions allows you to define and process texts using string parameters, for example, in order to create variable logs with FN 16: F-PRINT. In computing, a string designates a text.

Description of function

Within the Formula, Variable or String formula NC functions you can use the following string functions:

Syntax element

Meaning

NC function

DECLARE STRING

Assign a text to a QS parameter

Assigning text to a string parameter

DECLARE STRING

||

Concatenate contents of string parameters and assign them to a string parameter

Concatenating values of string parameters

  • String formula
  • Variable

TONUMB

Convert the value of a QS parameter to a numerical value and assign it to a numerical parameter

Converting the value of a string parameter to number

  • Formula
  • Variable

TOCHAR

Convert numerical value to a text and assign it to a string parameter

Converting numerical values to texts

  • String formula
  • Variable

SUBSTR

Copy a substring from a QS parameter and assign it to a string parameter

Copying a substring from a string parameter

  • String formula
  • Variable

SYSSTR

Read system data and assign the contents to a string parameter

Read system data with SYSSTR

  • String formula
  • Variable

INSTR

Search for a substring in a QS parameter and assign the retrieved characters to a numerical parameter

Searching for a substring within QS parameter contents

  • Formula
  • Variable

STRLEN

Determine the string length of a QS parameter and assign it to a numerical parameter

Determining the number of characters in QS parameter contents

  • Formula
  • Variable

STRCOMP

Compare QS parameters in ascending lexical order and assign the result to a numerical parameter

Comparing the lexical order of two texts

  • Formula
  • Variable

CFGREAD

Read the content of a machine parameter and assign it to a variable

Applying the contents of a machine parameter

  • String formula
  • Formula
  • Variable

The control provides the following options to enter formulas:

Read system data with SYSSTR

With the SYSSTR NC function you can read system data and save the contents in string parameters. Select the system datum by means of a group number ID and a number NR. Optionally, you can enter IDX and DAT.

SYSSTR only allows you to read alphanumeric values.

For numerical values, the control offers the FN 18: SYSREAD NC function. SYSSTR is programmed identically to FN 18: SYSREAD.

Read system data with FN 18: SYSREAD

In the general overview of the system data the alphanumeric values are marked with the text system string.

System data

 
Manual

Overview of the Machine Parameters, Error Numbers and System Data

The additional documentation Overview of the Machine Parameters, Error Numbers and System Data provides an overview of the following functions:

  • Machine parameters of the MPs for setters application
  • Preassigned error numbers of the FN 14: ERROR NC function (ISO: D14)
  • System data readable with the FN 18: SYSREAD (ISO: D18) and SYSSTR NC functions

ID 1445456-xx

You can download this documentation free of charge from the HEIDENHAIN website.

TNCguide

Assigning text to a string parameter

Before you can use and process texts, you must assign characters to the string parameters.

To assign a text to a string parameter:

    1. Select Insert NC function
    2. The control opens the Insert NC function window.

    1. Select String formula or Variable
    2. Define a variable name for the result
    3. Move cursor to the right
    4. If required, enter ""
    5. Enter the desired value between the quotation marks
    6. End the NC block

    1. Execute the NC block
    2. The control saves the entered value in the target parameter.
     
    Tip

    Alternatively, you can assign characters to a QS parameter using the DECLARE STRING NC function.

    In these examples, the control assigns a text to a string parameter.

    NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

    Change the following contents as needed:

    • Tools
    • Cutting parameters
    • Feed rates
    • Clearance height or safe position
    • Machine-specific positions (e.g., with M91)
    • Paths of program calls

    Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

    In addition, test the NC programs using the simulation before the actual program run.

     
    Tip

    With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

    11 QS10 = "workpiece"

    ; Assign text to the QS parameter QS10

    NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

    Change the following contents as needed:

    • Tools
    • Cutting parameters
    • Feed rates
    • Clearance height or safe position
    • Machine-specific positions (e.g., with M91)
    • Paths of program calls

    Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

    In addition, test the NC programs using the simulation before the actual program run.

     
    Tip

    With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

    11 {a} = "workpiece"

    ; Assign text to the named parameter {a}

    Concatenating values of string parameters

    With the || concatenation operator, you can concatenate the contents of multiple string parameters. This allows you, for example, to combine fixed and variable texts.

    To concatenate the contents of multiple string parameters:

      1. Select Insert NC function
      2. The control opens the Insert NC function window.

      1. Select String formula or Variable
      2. Define a string parameter for the result

      1. Confirm your input

      1. Select the backspace key, if required
      2. The control deletes the quotation marks.

      1. Select QS or Variable
      2. Enter the variable name

      1. Press the spacebar
      2. The control displays the currently available syntax elements.

      1. Select concatenation operator ||

      1. Select QS or Variable
      2. Enter the variable name

      1. End NC block
      2. After their execution, the control saves the substrings in succession as text in the target parameter.

      In these examples, the control concatenates the contents of two string parameters and assigns the result to a third string parameter.

      Parameter contents:

      • QS12 and {b}: Status:
      • QS13 and {c}: Scrap
      • QS10 and {a}: Status: Scrap

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      11 QS10 = QS12 || QS13

      ; Concatenate contents of QS12 and QS13 and assign them to the QS parameter QS10

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      11 {a} = {b} || {c}

      ; Concatenate contents from {b} and {c} and assign them to named parameter {a}

      Converting the value of a string parameter to number

      With the TONUMB NC function, you save exclusively numeric characters from a QS parameter to a different variable type. Then, you can use these values in calculations.

      In these examples, the control converts the variable value of a QS parameter to a numerical value. The control assigns this value to a numerical parameter.

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      11 Q82 = TONUMB ( SRC_QS11 )

      ; Convert value from QS11 to a numerical value and assign it to Q82

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      11 {a} = TONUMB ( SRC_QS11 )

      ; Convert value from QS11 to a numerical value and assign it to {a}

      Converting numerical values to texts

      With the TOCHAR NC function, you can save the content of a numerical parameter in a string parameter. You can concatenate the saved content with other string parameters, for example.

      In these examples, the control converts the numerical value of a Q parameter to a text. The control assigns this text to a string parameter.

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      11 QS11 = TOCHAR ( DAT+Q50 DECIMALS3 )

      ; Convert numerical value from Q50 to a text and assign it to the QS parameter QS11

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      11 {a} = TOCHAR ( DAT+Q50 DECIMALS3 )

      ; Convert numerical value from Q50 to a text and assign it to the named parameter {a}

      Copying a substring from a string parameter

      With the SUBSTR NC function, you can save a defined substring from a QS parameter in another string parameter. For example, you can use this NC function to extract the file name from an absolute file path.

      In these examples, the control saves the substring of a QS parameter in another string parameter. Using the BEG2 syntax element, you define that the control ignores the first two characters and starts copying from the third character. With the LEN4 syntax element, you define that the control copies the next four characters.

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      11 QS13 = SUBSTR ( SRC_QS10 BEG2 LEN4 )

      ; Assign substring from QS10 to the QS parameter QS13

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      11 {a} = SUBSTR ( SRC_QS10 BEG2 LEN4 )

      ; Assign substring from QS10 to the named parameter {a}

      Searching for a substring within QS parameter contents

      With the INSTR NC function , you can check whether a particular substring is contained within a QS parameter. This allows you to determine, for example, whether the concatenation of multiple QS parameters was successful. For the check, you must indicate two QS parameters. The control searches the first QS parameter for the content of the second QS parameter.

      If the substring is found, the control saves the number of characters until it reaches the occurrence of the substring in the result parameter. If multiple occurrences are found, the result is identical because the control saves the first one.

      If the substring searched for is not found, the control saves the total number of characters in the result parameter.

      In this example, the control searches a QS parameter for the text of a second QS parameter. When counting the characters, the control starts from zero. The control assigns the occurrence to the numerical parameter as a number.

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      37 Q50 = INSTR ( SRC_QS10 SEA_QS13 BEG2 )

      ; Search QS10 for substring from QS13

      Determining the number of characters in QS parameter contents

      The STRLEN NC function determines the number of characters in QS parameter contents. With this NC function, you can, for example, determine the length of a file path.

      If the selected QS parameter has not been defined, the control returns the value -1.

      In this example, the control determines the number of characters in a QS parameter. The control assigns the determined number to a numerical parameter.

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      11 Q52 = STRLEN ( SRC_QS15 )

      ; Determine the number of characters in QS15 and assign it to Q52

      Comparing the lexical order of two texts

      With the STRCOMP NC function, you can compare the lexical order of the content of two QS parameters.

      The control returns the following results:

      • 0: The content of the two parameters is identical
      • -1: In the lexical order, the content of the first QS parameter comes before the content of the second QS parameter
      • +1: In the lexical order, the content of the first QS parameter comes after the content of the second QS parameter

      The lexical order is as follows:

      1. Special characters (e.g., ?_)
      2. Numerals (e.g., 123)
      3. Uppercase letters (e.g., ABC)
      4. Lowercase letters (e.g., abc)
       
      Tip

      Starting from the first character, the control proceeds until the contents of the QS parameters differ from each other. If the contents differ starting from, for example, the fourth digit, the control aborts the check at this point.

      Shorter contents with identical strings are displayed first in the order (e.g., abc before abcd).

      In this example, the control compares the lexical order of the values of two QS parameters. The control assigns the result to a numerical parameter as a number.

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      11 Q52 = STRCOMP ( SRC_QS12 SEA_QS14 )

      ; Compare the lexical order of the values of QS12 and QS14

      Applying the contents of a machine parameter

      The NC function CFGREAD allows you to read out the values from machine parameters.

      Before using CFGREAD, you must program one QS parameter each with key, entity and attribute. Pay attention to enter the correct upper and lower case letters.

      The contents displayed in table view

      The NC function includes the following syntax elements:

      Syntax element

      Meaning

      KEY_QS

      QS parameter with the group name of the machine parameter (key)

      If no key is available, define the QS parameter without content.

      TAG_QS

      QS parameter with the object name of the machine parameter (entity)

      ATR_QS

      QS parameter with the name of the machine parameter (attribute)

      IDX

      Index of the machine parameter

      Number or numerical parameter

      Optional syntax element

       
      Tip

      You determine the required values using the table view of the configuration editor.

      The contents displayed in table view

      If the machine parameter contains numerical values, you can use the values in Q, QL, or QR parameters. The control always outputs numerical values in the metric system. Strings can be transferred in QS parameters. Named parameters allow the transfer of numerical values and strings.

      Examples

      In this example you transfer the overlap factor from the machine parameter pocketOverlap (no. 201001):

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      11 QS11 = "CH_NC"

      ; Assign the key to the QS parameter QS11

      12 QS12 = "CfgGeoCycle"

      ; Assign the entity to the QS parameter QS12

      13 QS13 = "pocketOverlap"

      ; Assign the attribute to the QS parameter QS13

      14 Q50 = CFGREAD( KEY_QS11 TAG_QS12 ATR_QS13 )

      ; Read out the contents of the machine parameter

      In this example you transfer the position of the tool touch probe in the Y axis (index 1) from the machine parameter centerPos (no. 114313):

      NC programs contained in this User's Manual are suggestions for solutions. The NC programs or individual NC blocks must be adapted before being used on a machine.

      Change the following contents as needed:

      • Tools
      • Cutting parameters
      • Feed rates
      • Clearance height or safe position
      • Machine-specific positions (e.g., with M91)
      • Paths of program calls

      Some NC programs depend on the machine kinematics. Adapt these NC programs to your machine kinematics before the first test run.

      In addition, test the NC programs using the simulation before the actual program run.

       
      Tip

      With a program test you determine whether the NC program can be used with the available software options, the active machine kinematics and the current machine configuration.

      11 QS11 = "TT140_2"

      ; Assign the key to the QS parameter QS11

      12 QS12 = "CfgTTRectStylus"

      ; Assign the entity to the QS parameter QS12

      13 QS13 = "centerPos"

      ; Assign the attribute to the QS parameter QS13

      14 {a} = CFGREAD( KEY_QS11 TAG_QS12 ATR_QS13 IDX1 )

      ; Read out the contents of the machine parameter

      Note

      If you use the String formula NC function, the result will always be a text. If you use the Formula NC function, the result will always be a numerical value.