Function: AsString
Function: AsString

Function: AsString

AsString ( INPUT )

Returns the string value of an input value.

Parameters

Parameter Type Description
INPUT VALUE The input value (any type).

Returns

VALUE(STRING) The string value of the input value.

What It Does

This function returns the input value or expression result as a string. Lists are output as bracketed lists with their values in index order separated by commas.

If the input value is already a string, it is returned as-is. This function does not change or convert a value in-place - you must reassign the result.

Example

The type of each of the values are most visible in a trace.

AsString Example


world
{
	start()
	{
		textln("asString(true) = "+asString(true));
		textln("asString(false) = "+asString(false));
		textln("asString(0) = "+asString(0));
		textln("asString(5.75) = "+asString(5.75));
		textln("asString(\"123\") = "+asString("123"));
		textln("asString(\"apple\") = "+asString("apple"));
		textln("asString(5 + 3) = "+asString(5 + 3));
		local a = 3.0;
		textln("asString(a) = "+asString(a));
		textln("a = "+a);
		a = [1, 2, 3.0, -4, 5 + 7.3, "oranges"];
		textln(asString(a));
		quit;
	}
}

Example Result Table

Value Result
BOOLEAN[false] > STRING > STRING[false]
BOOLEAN[true] > STRING > STRING[true]
FLOAT[Infinity] > STRING > STRING[Infinity]
FLOAT[-Infinity] > STRING > STRING[-Infinity]
FLOAT[NaN] > STRING > STRING[NaN]
INTEGER[0] > STRING > STRING[0]
FLOAT[0.0] > STRING > STRING[0.0]
INTEGER[10] > STRING > STRING[10]
INTEGER[3] > STRING > STRING[3]
FLOAT[10.0] > STRING > STRING[10.0]
FLOAT[3.0] > STRING > STRING[3.0]
FLOAT[10.5] > STRING > STRING[10.5]
FLOAT[3.5] > STRING > STRING[3.5]
INTEGER[-10] > STRING > STRING[-10]
INTEGER[-3] > STRING > STRING[-3]
FLOAT[-10.0] > STRING > STRING[-10.0]
FLOAT[-3.0] > STRING > STRING[-3.0]
FLOAT[-10.5] > STRING > STRING[-10.5]
FLOAT[-3.5] > STRING > STRING[-3.5]
STRING[] > STRING > STRING[]
STRING[ ] > STRING > STRING[ ]
STRING[0] > STRING > STRING[0]
STRING[0.0] > STRING > STRING[0.0]
STRING[10] > STRING > STRING[10]
STRING[3] > STRING > STRING[3]
STRING[10.0] > STRING > STRING[10.0]
STRING[3.0] > STRING > STRING[3.0]
STRING[10.5] > STRING > STRING[10.5]
STRING[3.5] > STRING > STRING[3.5]
STRING[-10] > STRING > STRING[-10]
STRING[-3] > STRING > STRING[-3]
STRING[-10.0] > STRING > STRING[-10.0]
STRING[-3.0] > STRING > STRING[-3.0]
STRING[-10.5] > STRING > STRING[-10.5]
STRING[-3.5] > STRING > STRING[-3.5]
STRING[apple] > STRING > STRING[apple]
STRING[banana] > STRING > STRING[banana]
STRING[NaN] > STRING > STRING[NaN]
STRING[infinity] > STRING > STRING[infinity]
LIST[[]] > STRING > STRING[[]]
LIST[[BOOLEAN[true], INTEGER[3], FLOAT[5.0], STRING[orange]]] > STRING > STRING[[true, 3, 5.0, orange]]
×

Modal Header