Constants (Literals) and Data Type Syntax

Type Format Examples
(1) Boolean literals

The following 4 literals are available:

  • 0

  • 1

  • TRUE

  • FALSE

n/a

(2) Integer literals

Decimal: <Literal>

Binary: 2#<Literal>

Octal: 8#<Literal>

Hexadecimal: 16#<Literal>

Decimal: 1234

Binary: 2#101010

Octal: 8#12

Hexadecimal: 16#1AF5

(3) Real literals n/a
  • 1.234

  • 1.234E-5

  • 1.233999956e-005

(4) Typed literals <Data type>#<Literal>

The following 15 data types are available.

  • BOOL#1

  • BYTE#12

  • WORD#123

  • DWORD#123

  • LWORD#123

  • SINT#123

  • INT#123

  • DINT#123

  • LINT#123

  • USINT#123

  • UINT#123

  • UDINT#123

  • ULINT#123

  • REAL#1.23

  • LREAL#1.23

(5) String literals

‘<String>’

The XEM CPU modules support up to 32 characters in a STRING data.

The following $ codes are available:

  • $N (New line)

  • $R (Carriage return)

  • $T (Tab)

  • $’ (Apostrophe)

  • $$ (Dollar sign)

‘ABC’

‘That$’s it!’

(6) Duration literals

TIME#<d>d<h>h<m>m<s>s<ms>ms

T#<d>d<h>h<m>m<s>s<ms>ms

  • d (Day)

  • h (Hour)

  • m (Minute)

  • s (Second)

  • ms (Millisecond)

Note: The XEM CPU modules don’t support ‘us’ and ‘ns’.

TIME#1d2h3m4s5ms

T#1d2h3m4s5ms

(7) Date literals
  • DATE#<yyyy>-<mm>-<dd>

  • D#<yyyy>-<mm>-<dd>

DATE#2023-01-01

D#2023-01-01

(8) Time-of-Day literals
  • TIME_OF_DAY#<hh>:<mm>:<ss>

  • TOD#<hh>:<mm>:<ss>

TIME_OF_DAY#12:34:45

TOD#12:34:45

(9) Date-and-Time literals
  • DATE_AND_TIME#<yyyy>-<mm>-<dd>- <hh>:<mm>:<ss>

  • DT#<yyyy>-<mm>-<dd>- <hh>:<mm>:<ss>

DATE_AND_TIME#2023-01-01-12:34:45

DT#2023-01-01-12:34:45

Array

The XEM CPU modules support up to 3 dimensional array.

  • <Variable name>[<Index1>]

  • <Variable name>[<Index1>, <Index2>]

  • <Variable name>[<Index1>, <Index2>, <Index3>]

Note: The index of array starts from 0 with the XEM CPU modules.

iA[2]

wB[iD, 4]

rC[iE, 6, 7]

 

 

LP307-7