Class_in

Homepage

Checks whether the specified value matches one of the items in a list (via a Parsing loop).

Result := Class_in(Value, MatchList, Delimiters = ",", OmitChars = "")

Parameters

Value The value used for comparisons.
MatchList List of values, each of which will be compared to Value for a match.
Delimiters Delimiters contains one or more characters (case sensitive), each of which is used to determine where the boundaries between substrings occur in MatchList.
OmitChars An optional list of characters (case sensitive) to exclude from the beginning and end of each substring.

Return Value

If a match is found, the index of the substring that matches the specified value.

If no match is found, the function returns 0.

Remarks

The values are compared using a case-insensitive equal (=).

Numbers are compared numerically.

If a match is found, ErrorLevel is set to the matching substring. If no match is found, ErrorLevel is not changed.

Related

if var in/contains MatchList, Parsing loop, "if Var in MatchList" is very slooooow

Class

Examples

var := 5.0

;returns true - in the list
if Class_in(var, "1,2,3,5,7,11") ;Avoid spaces in list.
    MsgBox Class_inA: %var% is a small prime number.

;returns false - not in the list
;Note that it compares the values as strings, not numbers.
if var in 1,2,3,5,7,11
    MsgBox %var% is a small prime number.


if Class_in(var, "1,2, 3, 5 , 7 , 11"  ,  ","  ,  " ") ;Don't worry about spaces
    MsgBox Class_inB: %var% is a small prime number.
List =
(LTrim
    iTem1
    ItEm2
    iTem3
)

;works great with continuation sections
if Class_in("item1", List, "`n")
{
    ;ErrorLevel contains the matching substring ("iTem1")
    MsgBox The matching substring is: %ErrorLevel%
}

Homepage