Function: StrJoin
Function: StrJoin

Function: StrJoin

StrJoin ( STRINGLIST, JOINER )

Joins a list of strings together into one string.

Parameters

Parameter Type Description
STRINGLIST VALUE(LIST) The list of strings.
JOINER VALUE(STRING) The joiner string to use between list items.

Returns

VALUE(STRING) The resultant string after the join.

What It Does

This function takes a list of strings and joins them together into one string, with the joiner string placed between each list item. Each list item is interpreted as its string representation on read. The joiner string is also interpreted as a string.

If the first parameter is not a list, it is converted to a list with the value as its only element.


	a = strJoin(["1", "2", "3", "4", "5"], " ");        // a = "1 2 3 4 5"
	a = strJoin(["apples", "pears", "oranges"], ", ");  // a = "apples, pears, oranges"
	a = strJoin([100, 200, true, false, 3.45], "");     // a = "100200truefalse3.45"

Example

String List Function Examples


world
{
	start()
	{
		// strSplit
		textln(strSplit("Apples and Oranges", " "));		// ["Apples", "and", "Oranges"];
		textln(strSplit(1001001, "00"));		            // ["1", "1", "1"];
		textln("");

		// strJoin
		textln(strJoin(["Apples", "and", "Oranges"], "|"));	// "Apples|and|Oranges"
		textln(strJoin([1, 2, 3, 4, 5], ":"));				// "1:2:3:4:5"
		textln(strJoin([[1, 2, 3], [4, 5]], " and "));		// "[1, 2, 3] and [4, 5]"
		textln("");
		
		// strParam
		local tokens = ["Apples", "and", "Oranges"];
		textln(strParam("Hope you like {2} {1} {0}!", tokens));	// "Hope you like Oranges and Apples!"
		textln(strParam("This parameterization does not work: {two} {-1} {5}!", tokens));

		quit;
	}
}
×

Modal Header