SUGIH4D Autom Solusi Super Scatter Zeus Sugih 4D

< All Topics
Print

CoDeSys – String Constants

Constants pour affichage CoDeSys

A string constant is a character string enclosed in single straight quotation marks. The characters are coded according to the character set specified in ISO/IEC 8859-1. Therefore, a string constant can include spaces and accented characters, as these belong to this character set. This is also referred to as a string literal, or simply a string.

Example: ‘Hello world!’

When a dollar sign ($) is in a string constant, the following two characters are interpreted as a hexadecimal code according to the coding in ISO/IEC 8859-1. The code also corresponds to ASCII code. In addition, please note the special cases.

Hexadecimal code
String with $ codeInterpretation
‘$<8-bit code>’8-bit code: Two-digit hexadecimal number that is interpreted according to ISO/IEC 8859-1.
‘$41’A
‘$A9’©
‘$40’@
‘$0D’Control character: Line break (corresponds to ‘$R’)
‘$0A’Control character: New line (corresponds to ‘$L’ and ‘$N’)
Special cases
String with $ codeInterpretation
‘$L’, ‘ $l’Control character: Line feed (corresponds to ‘$0A’)
‘$N’, ‘$n’Control character: New line (corresponds to ‘$0A’)
‘$P’, ‘$p’Control character: Form feed
‘$R’, ‘$r’Control character: Line break (corresponds to ‘$0D’)
‘$T’, ‘$t’Control character: Tab
‘$$’Dollar sign: §
‘$”Single straight quotation mark: ‘
Example
VAR CONSTANT
        constA : STRING := 'Hello world';
        constB : STRING := 'Hello world $21'; // Hello world!
END_VAR

Retour curseur et saut de ligne : ‘$R$L’ ou ‘$0D$0A’

Powered by WordPress