Searching for words in an array.
Posted: Sat Nov 25, 2023 7:02 pm
With some free time appearing, I've started trying to recall scripts. Unfortunately, I realize that I've forgotten a lot. For instance, I can't remember/write a simple function to find words in an array, although I think I did something like that in the spring.
I use version 7.9.1 and, unfortunately, I don’t want to install version 7.11, where the “convert” command was introduced.
Code: Select all
:local months [ :toarray "jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec"];
:local searchWord "nov";
:local result [:find $months $searchWord]
:put [ :typeof $result]
:if ($result > 0) do={
:put ("Word found at position " . $result)
} else={
:put "Word not found"
}