strSubstring(str:byte[],from:int,length:int)->byte[120]
Extracts a substring of a string from str, at the position (from) with a length (length).
Important note: Due to system limitations, the extracted string can have a maximum length of 119 characters (120-1).
print(strSubstring("This is a test",5,2)) # "is"
strFind(str:byte[],search:byte[])->int
Searches for a substring (search) in a string and outputs the position where the string is located. If nothing was found, -1 is returned.
print(strFind("This is a test", "test")) # 10
strLen(str:byte[])->int
Calculates the length of a string.
print(strLen("This is a test")) # 14
strToFloat(str:byte[])->float
Converts a string (byte[]) to a float type.
strToInt(str:byte[])->long
Converts a string (byte[]) into an int type.
strToBool(str:byte[])->bool
Converts a string (byte[]) into a bool type.
string.addInt(value:long)
Class: string
Converts and adds the integer number value to the current string.
s:string
s.addInt(4711)
s.draw(10,10)
update()
Draws “4711” on the screen.
string.clear()
Class: string
Clears the internal buffer of the string object.
s:string
s.add("Hello")
s.draw(10,10)
s.clear()
s.add("World")
s.draw(10,80)
update()
Draws “Hello” and “World” underneath each other.
string.addFloat(value:float)
Class: string
Converts and adds the float number value to the current string.
s:string
s.addFloat(3,145)
s.draw(10,10)
update()
Draws “3.145000” on the screen.
string.width()->int
Class: string
Based on the current font, calculates the width in pixels that the passed text will take up when output. This allows a text block to be centered or right-aligned.
s:string
textFont(FONT_ROBOTO_24)
s.add("Hello World!")
w = s.width()
s.draw(0,40)
s.draw(240-s.width(),100)
s.draw(120-s.width()/2,160)
update()
string.add(str:byte[])
Class: string
Adds a string to the string object.
s:string
s.add("hello")
s.add(" ")
s.add("World")
string.draw(x:int,y:int)
Class: string
Draws the contents of the string object at the x/y position on the screen.
s:string
s.add("x = ")
s.addInt(10)
s.draw(10,10)
update()