Skip to content

Literals

A literal is a constant value written directly in the source. logiccloud supports the IEC 61131-3 literal forms described below.

Decimal integers may use _ as a digit separator for readability.

1000
1_000_000

A literal can be typed by prefixing it with a type name and #:

INT#42
SINT#-5
UDINT#1_000

Bit-string and integer literals can be written in other bases with a base prefix and #. Digits may be grouped with _.

PrefixBaseExample
16#Hexadecimal16#FF, 16#DEAD_BEEF
8#Octal8#777
2#Binary2#1010_0001
mask := 16#00FF;
flags := 2#1010_1010;

Real literals contain a decimal point and may carry an exponent. They can be typed with REAL# / LREAL#.

3.14159
1.0E-9
-2.5E3
LREAL#6.022E23
TRUE
FALSE
BOOL#TRUE

0 and 1 are also accepted as boolean values where a BOOL is expected.

Single-byte strings (STRING) are written in single quotes; double-byte strings (WSTRING) in double quotes. Single characters use the CHAR# / WCHAR# prefix.

'Hello, world' // STRING
"Grüße" // WSTRING
CHAR#'A' // single CHAR
WCHAR#"Ω" // single WCHAR

The dollar sign $ introduces an escape inside a string or character literal:

EscapeMeaning
$$A literal dollar sign $
$'Single quote (in single-byte strings)
$"Double quote (in double-byte strings)
$L / $lLine feed
$N / $nNewline
$P / $pForm feed (page)
$R / $rCarriage return
$T / $tTab
$<hh>Single-byte character by hex code (two hex digits)
$<hhhh>Double-byte character by hex code (four hex digits, WSTRING)
line := 'Name:$TValue'; // tab between Name: and Value
quote := 'It$'s ready'; // embedded single quote
nul := '$00'; // a NUL character by hex code

A duration literal starts with T# (or TIME#) and combines day/hour/minute/ second/millisecond/microsecond/nanosecond components. LTIME# (or LT#) denotes a long duration.

UnitSuffix
Daysd
Hoursh
Minutesm
Secondss
Millisecondsms
Microsecondsus
Nanosecondsns
T#500ms
T#1h30m
T#2d4h30m15s
LTIME#10s500ms
T#-100ms // durations may be negative

Components must appear in descending order of magnitude and a fractional value is allowed on a component (e.g. T#1.5h).

KindPrefix(es)Example
DateD#, DATE#D#2026-06-08
Long dateLD#, LDATE#LD#2026-06-08
Time of dayTOD#, TIME_OF_DAY#TOD#14:30:00, TOD#14:30:00.250
Long time of dayLTOD#, LTIME_OF_DAY#LTOD#23:59:59.999
Date and timeDT#, DATE_AND_TIME#DT#2026-06-08-14:30:00
Long date and timeLDT#, LDATE_AND_TIME#LDT#2026-06-08-14:30:00.500
start := DT#2026-06-08-08:00:00;
midday := TOD#12:00:00;
today := D#2026-06-08;