日本語
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
The radix can be 2, 8, 10 or 16
| Format | Example | Data type handled for the example |
|---|---|---|
| DataType#Radix#Value | WORD#16#F | 000F as WORD |
| Radix#Value | 16#F | F in hexadecimal |
| Value | 10 | 10 in decimal |
| Value (with decimal point) | 1.0 | 1.0 as a real type |
| Data type | Example | Recommended (for clarity) |
|---|---|---|
| BOOL | TRUE | TRUE |
| BYTE | BYTE#16#0A, BYTE#10#10, 16#0A | BYTE#16#0A |
| WORD | WORD#16#000A, WORD#10#10, 16#A | WORD#16#000A |
| INT | INT#16#A, INT#10#10, 16#A | 10 |
| REAL | REAL#10.0 | REAL#10.0 For LREAL, 10.0 is fine (writing 10.0 gives an LREAL) |
| TIME | TIME#10s, T#1d1h23m45s | T#10.25s |
| DATE | DATE#1970-01-01, D#2026-06-10 | D#2026-06-10 |
| TIME_OF_DAY | TOD#00:00:00.0, TOD#23:59:59.999 | TOD#12:23:45.678 |
| DATE_AND_TIME | DT#1970-01-01-00:00:00.0 | DT#2026-06-10-12:23:45:.678 |
| STRING | 'ABC' + NULL (1985byte+NULL) | 'ABC' |
