@Member (JavaScript)

Returns the position of the first occurrence of a value in a string list.

Defined in

@Functions (JavaScript)

Syntax

@Member(value:string, list:any) : int
Parameter Description
value String value. This value must match an element in the list exactly including case for success.
list The list to check against.
Return value Description
int The position of the value in the list starting at 1, or 0 if no match occurs.

Usage

A list is an array.

Examples

This example subsets a list up to and including a specified member.
function p(stuff) {
	print("<<<" + stuff + ">>>"); 
 }

var cities = @List("Paris", "Berlin", "Moscow", "London");
var city = "Berlin";
var n = @Member(city, cities);
if(n > 0) {
	var citiesSubset = @Subset(cities, n);
	for(var i = 1; i <= @Count(citiesSubset); i++) {
		p(@Element(citiesSubset, i));
	}
} else {
	p(city + " is not listed");
}
/*
<<<Paris>>>
<<<Berlin>>>
*/