6 Programming
6-68
NJ-series CPU Unit Software User’s Manual (W501)
Note You cannot omit {data_type}# and just enter {base}#{numeric_value]. Any variables that are entered in that
form for instruction parameters result in errors.
Example: You cannot enter only #16#1A.
If different data types are used, an error may occur when you build the program. We therefore recommend
that you include {data_type}# when you specify data types.
Real Data
Note Express real-number variables as REALnumeric_value.
Example: Correct: REAL_variable:= REAL#3.14
Wrong: REAL_variable:=3.14;
Bit String Data
Note Express bit string data as bit_string_data_type#base#numeric_value.
Example: Correct: bit_string_variable:=WORD#16#3
Wrong: bit_string_variable:=3
• You cannot compare the sizes of bit string data types (BYTE, WORD, DWORD, and LWORD).
You must convert variables of these types to an integer data type with a data conversion
instruction (e.g., WORD_TO_UINT) before you can compare the values.
Example:
BCD_data : WORD
IF WORD_BCD_TO _UINT(BCD_data)> UINT#1234 THEN
• You cannot perform logic processing on integer data types (SINT, INT, DINT, LINT, USINT,
UINT, UDINT, and ULINT). You must convert variables of these types to a bit string data type
with a data conversion instruction (e.g., INT_TO_WORD) before you can perform logic opera-
tions.
Example:
a : INT
IF INT_TO_WORD(a) AND WORD#16#0001 THEN (*When a is odd*)
Notation Example Remarks
{data_type}#{base}#{numeric_value] LREAL#10#3.14 Data types: REAL or LREAL
Base: 10
{data_type}#{numeric_value] LREAL#3.14 This is interpreted as decimal data.
{numeric_value} 3.14 If {data_type} is omitted, the value is interpreted
as LREAL decimal data.
Bit Strings
Notation Example Remarks
{data_type}#{base}#{numeric_value] WORD#16#0064 • Data types: BYTE, WORD, DWORD, or LWORD
• Base: 2, 8, 10, or 16