Navigation:  Equipments (Devices) > PLC200 > Program > String >

STR_COPY_LAST

Cópia de Fim de Strings

Previous pageReturn to chapter overviewNext page

Block that performs a copy of a final section of STR, storing the result in DST.

 

Ladder Representation

 

STR_COPY_LAST_block

 

Block Structure

 

Variable Type

Name

Data Type

Description

VAR_INPUT

EN

BOOL

Block enabling

STR

STRING

Original STRING

LEN

BYTE

Number of characters to be copied from the end of STR

VAR_OUTPUT

DONE

BOOL

Output enabling

DST

BYTE

Variable that receives the new STRING

 

Operation

 

This block remains active as long as EN is at TRUE level, updating the value of DST according to the input parameters. DST receives a number of characters from STR1 defined by LEN from the final position of STR, returning toward the beginning.

 

The DONE value forwards to the next Ladder block the EN value when the operation is completed.

 

wpshelp_common_fig_note

NOTE!

If the size of DST is less than the number of characters copied from STR, the resulting value will be truncated.

 

Compatibility

 

Device

Version

PLC300

2.10 or higher

 

Block Flowchart

 

STR_COPY_LAST_flowchart

 

Example in Ladder

 

STR_COPY_LAST_example01

 

In the example above, zero characters are copied from final position STR1, and the result is sent to DST_6. When the block is ended successfully, the DONE output is activated. Note that, when LEN is zero, the output is always built as a null STRING.

 

STR_COPY_LAST_example02

 

In the example above, two characters are copied from final position STR1, and the result is sent to DST_6. When the block is ended successfully, the DONE output is activated.

 

STR_COPY_LAST_example03

 

In the example above, four characters are copied from final position of STR1, and the result is sent to DST_6. When the block is ended successfully, the DONE output is activated.

 

STR_COPY_LAST_example04

 

In the example above, eight characters are copied from final position STR1, and the result is sent to DST_6. When the block is ended successfully, the DONE output is activated. Note that if LEN is greater than the size of STR1, STR1 is copied in full, without generating an error.

 

STR_COPY_LAST_example05

 

In the example above, four characters are copied from final position of STR1, and the result is sent to DST_2. Since the size of DST_2 is 2, the last two characters copied are discarded. The block ends successfully, Done output is activated.

 

Example in ST

 

 The example below displays the instructions for applying the example above in the ST language.

 

 

VAR

   STR1 : STRING := '1234';

   LEN : BYTE := 4;

   DST_2 : STRING;

END_VAR

 

DST_2 := FB_STR_COPY_LAST(

   EN:=DI1,

   STR:=STR1,

   LEN:=LEN,

   Done=>DO1);