日本語 English

How to Write Constants and Literals

What Is a Constant?

A constant is a value that cannot be changed while the program is running. A variable can change its value while the program is running.
If you enter an initial value in the variable table and check Constant, the variable is treated as a constant

Literal

This summarizes how to write literals for the inputs of functions and function blocks
Types of notation
FormatExampleData type handled for the example
DataType#Radix#ValueWORD#16#F000F as WORD
Radix#Value16#FF in hexadecimal
Value1010 in decimal
Value (with decimal point)1.01.0 as a real type
The radix can be 2, 8, 10 or 16
Examples
Data typeExampleRecommended (for clarity)
BOOLTRUETRUE
BYTEBYTE#16#0A, BYTE#10#10, 16#0ABYTE#16#0A
WORDWORD#16#000A, WORD#10#10, 16#AWORD#16#000A
INTINT#16#A, INT#10#10, 16#A10
REALREAL#10.0 REAL#10.0
For LREAL, 10.0 is fine
(writing 10.0 gives an LREAL)
TIMETIME#10s, T#1d1h23m45sT#10.25s
DATEDATE#1970-01-01, D#2026-06-10D#2026-06-10
TIME_OF_DAYTOD#00:00:00.0, TOD#23:59:59.999TOD#12:23:45.678
DATE_AND_TIMEDT#1970-01-01-00:00:00.0DT#2026-06-10-12:23:45:.678
STRING'ABC' + NULL (1985byte+NULL)'ABC'

Comments