2 Instruction Descriptions
2-504
NJ-series Instructions Reference Manual (W502)
StringSum
The StringSum instruction calculates the checksum for a text string.
The StringSum instruction calculates the checksum of text string to process In. Checksum Out will be
the number of bytes specified with byte size Size. Out is given as a hexadecimal text string with a NULL
character stored at the end.
The following example is for when In is ‘1234’ and Size is USINT#2.
If Size was USINT#1 in the above example, Out would be ‘A’.
Instruction Name FB/FUN Graphic expression ST expression
StringSum Checksum Calcula-
tion
FUN Out:=StringSum(In, Size);
Variables
Name Meaning I/O Description Valid range Unit Default
In Text string
to process
Input
Text string to process Depends on data type. --- ''
Size Byte size Byte size of checksum 1 or 2 Bytes 1
Out Checksum Output Checksum Number of bytes speci-
fied by Size
Bytes
---
Boolean
Bit strings Integers
Real
numbers
Times, durations,
dates, and text strings
BOOL
BYTE
WORD
DWORD
LWORD
USINT
UINT
UDINT
ULINT
SINT
INT
DINT
LINT
REAL
LREAL
TIME
DATE
TOD
DT
STRING
In OK
Size OK
Out OK
Function
(@)StringSum
EN ENO
In Out
Size
abc:=StringSum(’1234’, USINT#2);
LD ST
‘1234’
abc
USINT#2
StringSum
EN ENO
In
Size
‘1234’
In
31 3433
‘CA’
Byte size Size = USINT#2
Total calculated.
Character codes
32
Out = abc