Object Methods
Subprogram within Objects

Mint has many objects, and within these objects are subprograms that are not part of any library. Here they are: Lists Lists are data structures that can hold values of any type. They are declared with a comma separated list of items inside square brackets. `list.length()` Returns the number of items in the list. Same as `list.size()`. `list.pop()` Removes the last item in the list and returns it. `list.remove(i)` Removes the ith item in the list and returns it. `list.reverse()` Reverses the list. `list.find(item)` Finds the item in the list and returns the position of the item in the list. If the item cannot be found, returns -1. `list.append(item)` Attaches the item to the end of the list. Same as `list.add(item)`. `list.sliceToEnd(i)` Returns the sublist of this list, starting at item number i. `list.slice(a, b)` Returns the sublist of this list, starting at item number a and ending at item number b - 1. `list.replaceSlice(a, b, list)` Replaces the list's sublist from position a to position b - 1 with the new sublist list. Strings Strings are variables that hold text. They are declared with quotes surrounding a series of zero or more characters. `str.length()` Returns the number of characters in the string. Same as `str.size()`. `str.split(substr)` Splits the string around the substring substr, and returns a list of the split parts. For example, "hi hello bye".split(" ") will return ["hi", "hello", "bye"]. `str.charNum()` Returns the numerical representation of the first ASCII character of this string. `str.find(substr)` Returns the position of the substring substr in this string. `str.slice(a, b)` Returns the substring starting at character position a and ending at position b - 1. `str.sliceToEnd(i)` Returns the substring starting at character position i and ending at the end of the string. `str.replaceSlice(a, b, slice)` Replaces the substring starting at character a and ending at character b - 1 with the new string slice. `str.upper()` Returns the string with all uppercase characters. `str.lower()` Returns the string with all lowercase characters. `str.startsWith(substr)` Returns true if the string starts with substr. `str.endsWith(substr)` Returns true if the string ends with substr. `str.replace(a, b)` Replaces all instances of a in the string with b. `str.remove(a)` Removes all instances of a in the string. Bytes Bytes are lists that can only hold integers between 0 and 255. `bytes.length()` Returns the number of items in the bytes list. Same as `bytes.size()`. `bytes.append(b)` Attaches b to the end of the bytes list. Same as `bytes.add(b)`. `bytes.get(i)` Returns the ith byte in the bytes list. `bytes.set(i, value)` Set the ith byte in the bytes list to be equal to value. Windows Windows are rectangular frames used for drawing buttons and graphics. `window.setSize(a, b)` Sets the size of the window to be a x b. `window.display()` Makes the window visible. `window.hide()` Makes the window invisible. `window.setTitle(t)` Sets the window's title to be t. `window.pack()` Adjust the sizing and placement of the window and its contents. `window.setLocation(x, y)` Moves the window to (x, y). `window.add(b)` Adds button b to this window. `window.setBgColor(rbg)` Sets the background color of the window to rbg. rbg must be a list of three integers between 0 and 255. `window.setDrawingColor(rbg)` Sets the drawing color of the window to rbg. rbg must be a list of three integers between 0 and 255. `window.drawShape(s)` Draws the shape s onto the window. Shapes can be arcs, lines, ovals, rectangles, or polygons. `window.clearShapes()` Removes drawn shapes from the window. Buttons Buttons are clickable widgets that can be placed into a window. `button.enable()` Allows the button to be clicked. `button.disable()` Prevents the button from being clicked. `button.setText(t)` Sets the display text of the button to t. `button.setSubprogram(s)` Sets the subprogram that will be executed when the button is clicked. `button.setSize(a, b)` Sets the size of the button to be a x b. `button.setPosition(x, y)` Sets the position of the button to be (x, y) within the window. Previous Lesson: Documentation Next Lesson: (None) Table of Contents