1. Convert integers to string I_S

1. Convert integers to string I_S 

1.1. Instruction Description

Convert the input single word integer (IN) into an 8-byte string starting from the address (OUT) according to the format mask (FMT). The last 9th byte is represented by a 0 indicating the end bit.

Format Mask (FMT) assigns precision after decimal point and whether to use dots or commas to represent decimal points.

The length of the output string is always 8 characters. The number of decimal places to the right of the output buffer is allocated by the nnn field. The valid range for the nnn field is 0 to 5. If a zero digit is assigned to the right of the decimal point, the converted value will have no decimal point. For values greater than 5, output as a string consisting of 8 ASCII space characters. Specify whether to use a comma (c=1) or a decimal point (c=0) as the separator between the integer and decimal parts. The most significant 4 bits of the format must be zero.

The following figure also provides an example of a value in the format of using a decimal point (c=0) with three digits to the right of the decimal point (nn=011). The value at OUT is the length of the string stored in the next byte address.

Exchange example

图1 Exchange example

1.2. Attention

a) The OUT string (including the generated end bit) will overwrite all data of the original software component.

b) The encoding of the string is ASCII (ISO/IEC 646), please do not use other encoding methods such as UTF-8, Unicode, etc.

1.3. The valid operands of the instruction

Input/Output Data Type operand Description
IN 16 bit integer D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) Input
FMT 16 bit unsigned integer D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) Format
OUT 16 bit unsigned integer D/CV/TV/AO/V/Z, bit composite word (Y/M/C/T/S), local variable (LW) output

1.4. Example

Command table:

NETWORK 000

LDP X000//String operations are time-consuming, so try to use edge conditions to trigger them.

I2 K12345 H8 D10//Convert integer K12345 to a string starting from D10, where c=1 (using dots) and nn=0 (without decimal data)

IS

图2 IS