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

STR_FIND_LAST

Busca Última Ocorrência de Strings

Previous pageReturn to chapter overviewNext page

Block that searches for the last occurrence of one STRING in another, returning the position of this occurrence.

 

Ladder Representation

 

STR_FIND_LAST_block

 

Block Structure

 

Variable Type

Name

Data Type

Description

VAR_INPUT

EN

BOOL

Block enabling

STR1

STRING

STRING where the search will be performed

STR2

STRING

STRING to be searched

VAR_OUTPUT

DONE

BOOL

Output enabling

POS

BYTE

Position where STR2 was found

 

Operation

 

This block remains active as long as EN is at TRUE level, updating the value of POS according to the input parameters.

A search in STR1 is performed, from its last position, by an occurrence of STR2.

 

If it is found, it inserts into the POS the occurrence of this position, while DONE forwards to the next Ladder block the value of EN when ending the operation.

 

If it is not found, DONE remains FALSE and POS remains unchanged.

 

wpshelp_common_fig_note

NOTE!

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

 

Compatibility

 

Device

Version

PLC300

2.10 or higher

 

Block Flowchart

 

STR_FIND_LAST_flowchart

 

Example in Ladder

 

STR_FIND_LAST_example01

 

In the example above, a search is done by STR2 in STR1 from its final position. Since STR2 is found in position 4, POS receives 4. The block ends successfully, the DONE output is activated.

 

STR_FIND_LAST_example02

 

In the example above, a search is done by STR2 in STR1 from its final position. Since STR2 is found in position 2, POS receives 4. The block ends successfully, the DONE output is activated.

 

STR_FIND_LAST_example03

 

In the example above, a search is done by STR2 in STR1 from its final position. Since STR2 is not found, POS remains unchanged and the DONE output is disabled.

 

Example in ST

 

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

 

 

VAR

   STR1 : STRING := '2232';

   STR2 : STRING := '1';

   POS : BYTE;

END_VAR

 

POS := FB_STR_FIND_LAST(

   EN:=DI1,

   STR1:=STR1,

   STR2:=STR2,

   Done=>DO1);