Skip to content

is_string

drewmccluskey edited this page Nov 28, 2018 · 7 revisions

is_string

Returns whether the given input is a string.

Syntax:

is_string(n);
Argument Description
n The variable to check.

Returns: Boolean

Description

This function returns if the input variable is a string or not. If so, it returns true, if not, returns false.

Example:

var1 =Hello, World!if is_string(var1)
{
message =var1 is a string!}

The above code checks to see if var1 is a string, and if it is, sets the variable message to “var1 is a string!”. This can be used to make sure a variable is a string before printing it, and if not, converting it into a string.

Example 2:

if is_string(str)
{
draw_text(0,0,str);
}
else 
{
str = sstring(str);
draw_text(0,0,str);
}

The above code checks if str is a string, and if so, draws the text on the screen. If not, it will convert str to a string and then draw it.

Clone this wiki locally