Text
- Updated2025-10-31
- 2 minute(s) read
Define data types to contain strings using the text data type.
Define PAscript variables with the text data type as a local or global variable.
Global Text Variables
To define a global variable in PAscript, use the text data type and the variable name in a section globals code block.
Example: Global Text Variable
program
section globals
text t
endsection
...
endprogram
Local Text Variables
To define local text variables, specify the text data type and the maximum length of the variable. Indicate the length in parentheses.
text identifier(Length) = initialization
The initialization after the identifier is optional. If you do not specify initialization, the variable is initialized with the empty string "".
The maximum length can also be a variable of the int32 type for local text variables.
Specify non-printable characters in HEX. For example, specify 0x3 for ETX (End of Text).
Example: Local Text Variable
program text t(10) // content of variable is "" text t1(11) = "Hello" + "X" // corresponds to "Hello X" text t2(1) = 0x15 endprogram
Text as Parameter of a User-Defined Function
If you use the text data type as a parameter of a user-defined function, only the data type is used. No maximum text length is specified.
Example: Text as a Parameter of a User-Defined Function
program
section globals
text a
endsection
myTextFunction(a)
endprogram
function myTextFunction(text t)
text localText(500)
localText = t
sys:logInfo(sys:ui,"%s",localText)
endfunction
Operators
Link text using the + operator.
Example: + Operator
program
section globals
// global variables
text target, source
endsection
target = "Hello" + "world" + "\n" + source
endprogram
Special Characters
Use umlauts and most of the printable special characters in variables of the text type without restrictions. One exception is the backslash \. The backslash serves as an escape character and must be masked for the output in a text with an additional backslash.
| Escape Sequence | Output |
|---|---|
| \n | Change to the next line |
| \r | Start with the first character of the current line |
| \0 | NULL character |
| \\ | Output of the backslash in the text |
Related Information
- Text Concatenation
Concatenate texts using sprintf or using the + operator. The operator is an easy way to link text together.