Oxoscript turns into NanoPy - more infos

String functions

strCompare

Makes a lexicographical comparison. If the strings are identical, 0 is returned. If the first string is to be classified before the second, the number is negative, otherwise it is positive.

t1 = "ABC"
t2 = "DEF"

print strCompare(t1,t2)
print strCompare(t2,t1)
print strCompare(t1, "ABC")

isEqual

  isEqual(str1:byte[], str2:byte[])->bool

Makes a lexicographical comparison. If the strings are identical, true is returned.

t1 = "test"

print isEqual(t1, "test")

strSubstring

  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

  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

  strLen(str:byte[])->int

Calculates the length of a string.

print(strLen("This is a test")) # 14

strToFloat

  strToFloat(str:byte[])->float

Converts a string (byte[]) to a float type.

strToInt

  strToInt(str:byte[])->long

Converts a string (byte[]) into an int type.

strToBool

  strToBool(str:byte[])->bool

Converts a string (byte[]) into a bool type.

string.addInt

  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

  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

  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

  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

  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

  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()