Search for the index of an element in an int32
array stored on an SD card by its value. The function returns the index of the first occurrence, or—if start_index is provided—starts searching from that position.
An SD card is required to use this function.
In the function menu | On the diagram |
---|---|
![]() |
![]() |
Name | Value Type | Description |
---|---|---|
id |
int32 |
File identifier.The file identifier is used to generate the file name on the SD card. For more details, see the SD card article |
get |
bool |
Search trigger. The function starts on a rising edge and keeps trying until completed successfully, an error occurs, or it receives False at the get input. |
start index |
int32 |
Index of the element from which the search should begin. The first element in the buffer has index 0. |
value |
int32 |
The value to search for in the array. |
Name | Value Type | Description |
---|---|---|
index |
int32 |
Index of the found element, or -1 if not found |
ended |
bool |
Indicates whether the function has finished execution: 1 – finished 0 – not finished |
status |
int32 |
Function status: 0 – idle 1 – opening 2 – closing 3 – closing (after error) 4 – seeking 5 – reading -1 – operation not supported -2 – operation not available -3 – file not accessible -4 – invalid element index -5 – error |
0 -> 1 -> 5 -> 2 -> 0 // final status on success
| | |
| | * -> 3 -> [-1 .. -5] // error during execution
| |
| * -> 3 -> [-1 .. -5] // error after opening
|
* -> [-1 .. -5] // error before opening
None
Find the element equal to 2500 in the file array:
Now find the next occurrence. To do this, pass index + 1 to the start_index input.
If you don’t increment the index, the function will return the same result again: