Skip to content
Mistium edited this page Nov 7, 2023 · 10 revisions

About

Arrays in OSL are defined by [] and can have any length and any data type in any item

So you can have arrays of arrays with json objects and integers if you really want

Example array:

["Hello","Wow",100,{"huh":10}]

Commands

Defining an array

type the name of the array and then = and then the array data

array = ["test","data"]

Array Functions:

  • .append("string")

    • Adds a new element (in this case, a string) to the end of an array.
    • Example: ["hi"].append("goodbye") results in ["hi", "goodbye"].
  • .index("string")

    • Finds the index of a specific element (string) in an array.
    • Example: ["hi", "goodbye"].index("hi") returns 1, with array indices starting from 1.
  • .delete(int)

    • Removes an element at a specific index from an array.
    • Example: ["hi", "goodbye"].delete(1) returns ["goodbye"].
  • .item(int) or .[int]

    • Retrieves the item at a specific index in the array.
    • Example: ["hi", "goodbye"].item(1) or ["hi", "goodbye"].[1] returns "hi".
  • .join("string")

    • Combines all elements of an array into a single string, separated by the specified separator.
    • Example: ["hello", "how are you"].join(", ") returns "hello, how are you".
  • .split("string")

    • Splits a string into an array of substrings, separated by the specified separator.
    • Example: "hello, how are you".split(" ") returns ["hello,", "how", "are", "you"].

originOS Wiki

Wiki Views:
:views

OSL | RSH | ICN

Clone this wiki locally