I have a block!
x: ["one" "two" "three"]
index? find x "two"
returns... 2
index? find x "four"
returns...
** Script Error: index? expected series argument of type: series port
** Near: index? find x "twos"
What's the best way to have index? return none
rather than the error?
>> help index?
USAGE:
INDEX? series /xy
DESCRIPTION:
Returns the index number of the current position in the series.
INDEX? is an action value.
ARGUMENTS:
series -- (Type: series port)
REFINEMENTS:
/xy -- Returns index as an XY pair offset.
index? expects a series. If the argument is none, it will raise an error.
>> find x "four"
== none
You can either check if the argument exists or is a series or guard against the error e.g.
>> if series? i: find x "four" [index? i]
== none
or
>> attempt [index? find x "four" none]
== none