Function: StrConcat
Function: StrConcat

Function: StrConcat

StrConcat ( STRING1, STRING2 )

Concatenates two strings together and returns the result.

Parameters

Parameter Type Description
STRING1 VALUE(STRING) The first string.
STRING2 VALUE(STRING) The second string.

Returns

VALUE(STRING) The result of concatenating two strings together.

What It Does

This returns the result of concatenating two strings together, such that the first string is placed before the second. Both provided values are interpreted as strings before they are concatenated together.


	a = strConcat("apple", "sauce"); // a = "applesauce"
	a = 6 + 4;                       // a = 10
	a = strConcat(6, 4);             // a = "64"

Example

String Manipulation Examples


world
{
	start()
	{
		// Concatenation
		textln("to" + "gether");                                // "together" 
		textln(strConcat("to", "gether"));                      // "together" 
		textln(strConcat(strConcat("to", "gether"), "ness"));	// "togetherness"
		textln(4 + 5);											// 9
		textln(strConcat(4, 5));								// "45" (both values are converted to strings first)
		textln("");

		// Substring
		textln(substring("applejack", 0, 5));		// "apple" 
		textln(substring("applejack", 5, 9));		// "jack" 
		textln(substring("applejack", 9, 5));		// "" 
		textln(substring("applejack", -3, 100));	// "applejack" = substring("applejack", 0, 9)
		textln(substring(123, 0, 1));				// "1" (first value is converted to a string first)
		textln("");

		// Lower-case convert.
		textln(strLower("Apples and Oranges"));		// "apples and oranges"
		textln(strLower("HELLO!!!"));				// "hello!!!"
		textln(strLower("123456789"));				// "123456789"
		textln("");
		
		// Upper-case convert.
		textln(strUpper("Apples and Oranges"));		// "APPLES AND ORANGES"
		textln(strUpper("hey."));					// "HEY."
		textln(strUpper("123456789"));				// "123456789"
		textln("");

		// Get single character.
		textln(strChar("Apples and Oranges", 0));	// "A"
		textln(strChar("This is a string.", 5));	// "i"
		textln(strChar(12345, 2));					// "3" (converted to string first)
		textln(strChar("apple", -1));				// "" (out of range)
		textln("");

		// string trim.
		textln(strTrim("      apple"));				// "apple"
		textln(strTrim("apple      "));				// "apple"
		textln(strTrim("   apple   "));				// "apple"
		textln(strTrim("\tapple\t"));				// "apple"
						 
		quit;
	}
}
×

Modal Header