@Length (JavaScript)

Returns the number of characters in a string.

Defined in

@Functions (JavaScript)

Syntax

@Length(value:string) : int
Parameter Description
value String or array of strings to be checked.
Return value Description
int Length of the string or each element of the string array.

Usage

If the parameter is a string, the result is the length of that string. If the parameter is an array of strings, the result is an array containing the length of each string.

Examples

This example parses a string extracting and trimming elements separated by commas. The elements form one array and a second array holds their lengths.
function p(stuff) {
	print("<<<" + stuff + ">>>");
}

var mystring = "  cats , trees,  houses, bikes ";

if(@Length(@Trim(mystring)) == 0) { // Make sure string is not empty
	p("No data");
	return;
}
var mylist = new Array();
while(@Contains(mystring, ",") == @True()) {
	mylist.push(@Trim(@Left(mystring, ",")));
	mystring = @Trim(@Right(mystring, ","));
}
mylist.push(@Trim(mystring));
var mylistlen = @Length(mylist); // Create array with token lengths

for(var i = 0; i < mylist.length; i++) {
	p(mylist[i] + " " + mylistlen[i]);
}