Format strings
Application
The control provides the FMT syntax element for QS parameters and named parameters to define format strings. Using format strings, you no longer have to convert numerical values or concatenate strings.
You can use format strings in the following NC functions, for example:
- String formula
- SQL SELECT
- TEXT within FUNCTION REPORT
Related topics
- Types of variables
- Assign text to a string parameter
- Concatenate values of string parameters
Requirements
- Code number 555343
- Variables defined beforehand that are programmed within a format string
Description of function
The FMT syntax element allows you to define format strings. Program format strings in the text mode of the Program workspace.
The syntax of the format strings is based on the f strings in Python. After the syntax initiator follows the string between double quotation marks. You can embed variables in the string using curly brackets. Once the NC block has been executed, the string contains the values of the embedded variables.
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.
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 Q1 = +7 | ; Numerical value |
12 QS1 = "TNC" | ; Alphanumeric value |
13 QS2 = FMT"ENJOY {QS1}{Q1}" | ; Result after execution: |
Influencing the formatting of the string is also possible (e.g., by defining whether or not and how the control outputs algebraic signs). You define the formatting inside the curly brackets after a colon.
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.
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 Q1 = +7 | ; Numerical value |
12 QS1 = FMT"{Q1:+}" | ; Result including algebraic sign after execution: |
Formatting
A variety of formatting options is available, depending on the variable type and the values.
When you program formatting options, you must observe the following sequence:
[[fill character] alignment] [sign] ['0'] [field width] ['.' accuracy] [type]
- [ ] are not programmed and only serve as separators within the sequence.
- ' ' are not programmed, however they contain the character to be programmed or an example input.
- '0' between the sign and the field width can be used as a fill character for numerical values.
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.
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 QS2 = FMT"{QS1:X>10}" | ; [[Fill character] alignment] [field width] |
12 QS3 = FMT"{Q1:+.2f}" | ; [Sign] ['.' accuracy] [type] |
Fill character, alignment and field width
Formatting character or example | Meaning |
---|---|
[Fill character] (e.g., 'X') | In connection with alignment and field width you can optionally define fill characters that replace any existing blank spaces. |
< | Left-aligns the text within the available field width Default setting that is also effective without input |
> | Right-aligns the text within the available field width |
^ | Centers the text within the available field width |
[Field width] (e.g., '10') | You can define the field width as the number of places. If you define a field width that is smaller than the number of characters of the string, the value will have no function. If you do not define a value, the content will determine the field width. |
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.
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 QS1 = "LEFT" | ; Alphanumeric value |
12 QS2 = "RIGHT" | ; Alphanumeric value |
13 QS3 = FMT"{QS1:<4}{QS2:>6}" | ; Result including algebraic sign after execution: |
14 QS4 = FMT"{QS1:X>10}" | ; Result including algebraic sign after execution: |
Algebraic sign
Formatting characters | Meaning |
---|---|
+ | Outputs the sign for negative values as well as positive values |
- | Outputs the sign for negative values only Default setting that is also effective without input |
Spaces | If a space character is programmed as a formatting character, positive values will induce the control to output a leading space character. |
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.
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 Q1 = +7 | ; Numerical value |
12 QS1 = FMT"{Q1}{Q1:+}" | ; Result after execution: |
Integers
Formatting characters | Meaning |
---|---|
d | Outputs a decimal integer If you program this formatting for a floating-point number, the control will abort program run with an error message. If you do not define a type, the control will use the default setting for decimal numbers. |
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.
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 Q1 = +1 | ; Numerical value is integer |
12 QS1 = FMT"{Q1:d}" | ; Result after execution: |
13 Q1 = +1.23 | ; Numerical value is decimal number |
14 QS1 = FMT"{Q1:d}" | ; Program cancellation with error message |
Decimal numbers
Formatting characters | Meaning |
---|---|
[Accuracy] (e.g., '.2') | You can define the accuracy of the output (e.g., by the number of decimal places for fixed-point numbers f). The effect of the accuracy varies, depending on the combination with the following formatting signs. |
e | Outputs the exponent representation with e as a separator |
E | Outputs the exponent representation with E as a separator |
f | Outputs a decimal fixed-point number Define the number of decimal places using the accuracy. If you do not define an accuracy, the control will use the default value '6'. |
g | Depending on the value, the control automatically decides on the type of representation, for example, the exponent representation using e as separator. An additional accuracy allows you to define the number of significant digits to which the value is rounded by the control. If you do not define an accuracy, the control will use the default value '6'. |
G | Like type g, but using E as separator for the exponent representation |
Default [type] | If you program neither type nor accuracy, the control will use type g with an unlimited accuracy. The default type '6' does not apply in this case. |
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.
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 Q1 = +1.23 | ; Numerical value |
12 QS1 = FMT"{Q1:e}" | ; Result after execution: |
13 QS1 = FMT"{Q1:E}" | ; Result after execution: |
14 QS1 = FMT"{Q1:f}" | ; Result after execution: |
15 Q1 = +0.0000123 | ; Numerical value |
16 QS1 = FMT"{Q1:f}" | ; Result after execution: |
17 QS1 = FMT"{Q1:g}" | ; Result after execution: |
18 QS1 = FMT"{Q1:G}" | ; Result after execution: |
19 Q1 = +123.456 | ; Numerical value |
20 QS1 = FMT"{Q1:.2}" | ; Result after execution: |
21 QS1 = FMT"{Q1:.2f}" | ; Result after execution: |
22 QS1 = FMT"{Q1:.2g}" | ; Result after execution: |
23 QS1 = FMT"{Q1:.3}" | ; Result after execution: |
Definition
Significant digits
Significant digits are the places of a number which contain valuable information. These digits start from the first number after the leading zeros, if applicable, and end with the last still meaningful number. For example, you can restrict a probing result to a number of significant digits by programming an accuracy.
Notes
- The control exclusively supports the described formatting options.
- If you, for example, apply a formatting for decimal numbers to texts, the control will abort the program run with an error message.