6.5 Variables
6.5.5 Constants
GM Programmer allows the use of constants.
Constants are declared according to the following syntax.
VAR CONSTANT
Constant name:Type:=Default value;
END_VAR
Type
Constant type
BOOL
BOOL
Types that can be used
Integer
as numerical values
Decimals and
REAL / LREAL
exponents
Time
TIME
Time
LTIME
Time
TIME_OF_DAY
Date
DATE
Date and time
DATE_AND_TIME
Character
STRING, WSTRING
string
6.5.6 Object for Global Variable Declaration
GM Programmer allows the use of global variables that can be used within the entire project.
■
Global variable list
This is an object for declaring global variables.
6-24
Description
TRUE (1), FALSE (0)
Binary, octal, decimal, and hexadecimal numbers
For numbers other than decimal numbers, integer constants are
entered after number base and #.
Examples: 14, 2#0101, 8#27, 16#34AB
Decimals and exponents
Examples: 1.4, 2.34e+008
32-bit time constants compliant with IEC 61131-3
Syntax: t#, T#, time#, TIME#
Examples: T#12ms, T#12h32m24s
64-bit time constants
In addition to TIME constants, the following units can be used.
Microsecond: m
Nanosecond: ns
Syntax: LTIME#
Example: LTIME#123m456ns
Time
Syntax: tod#, TOD#, time_of_day#, TIME_OF_DAY#
Example: tod#12:24:20.123
Date
Syntax: d#, D#, date#, DATE#
Example: d#2018-01-01
Date and time
Syntax: dt#, DT#, date_and_time#, DATE_AND_TIME#
Example: dt#2018-01-01-07:04:13
Enclosed with single quotation marks
Example: 'Hello World'
WUME-GM1RTXOP-01