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

STR_DELETE

Deleta Seções de Strings

Previous pageReturn to chapter overviewNext page

Block that deletes part of a section of STR, storing the remainder in DST.

 

Ladder Representation

 

STR_DELETE_block

 

Block Structure

 

Variable Type

Name

Data Type

Description

VAR_INPUT

EN

BOOL

Block enabling

STR

STRING

Original STRING

POS

BYTE

Position from which the removal will begin

LEN

BYTE

Number of characters to be removed from POS

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. A section defined by the POS initial position is removed from STR and a LEN size, and the final result is stored in DST.

 

If POS is outside the allowable range of values (between 1 and the size of STR), DONE receives FALSE and DST remains unchanged.

 

If successful, the DONE value forwards to the next Ladder block the EN value when the operation is completed.

 

wpshelp_common_fig_note

NOTE!

POS is treated with index "based one". That is, POS = 1 references the first position of STR.

 

wpshelp_common_fig_note

NOTE!

If the size of DST is less than the sum of the number of remaining characters in STR, the resulting value will be truncated.

 

Compatibility

 

Device

Version

PLC300

2.10 or higher

 

Block Flowchart

 

STR_DELETE_flowchart

 

Example in Ladder

 

STR_DELETE_example01

 

In the above example, as the value of POS is invalid, the block is not completed successfully, and the DONE output is disabled.

 

STR_DELETE_example02

 

In the example above, two characters are deleted from position 2 of STR1, and the remaining characters are sent to DST_6. When the block is ended successfully, the DONE output is activated.

 

STR_DELETE_example03

 

In the example above, two characters are deleted from position 4 of STR1, and the remaining characters are sent to DST_6. When the block is ended successfully, the DONE output is activated. Note that if POS + LEN is greater than the size of STR1, only the remaining characters are deleted from STR1, without generating an error.

 

STR_DELETE_example04

 

In the example above, five characters are deleted from position 3 of STR1, and the remaining characters are sent to DST_6. When the block is ended successfully, the DONE output is activated. Note that if POS + LEN is greater than the size of STR1, only the remaining characters are deleted from STR1, without generating an error.

 

STR_DELETE_example05

 

In the example above, one character is deleted from position 1 of STR1, and the remaining characters are sent to DST_2. Since the size of DST_2 is 2, the last character copied is 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 := 'ABCD';

   POS : BYTE := 1;

   LEN : BYTE := 1;

   DST_2 : STRING;

END_VAR

 

DST_2 := FB_STR_DELETE(

   EN:=DI1,

   STR:=STR1,

   POS:=POS,

   LEN:=LEN,

   Done=>DO1);