Skip to content
Mistium edited this page Sep 10, 2024 · 11 revisions

Variable Assignment:

  • variablename = "assign-data":

    • Description: Sets a variable with the specified name (variablename) to the inputted data ("assign-data").

    • Example:

      count = 10

      This sets the variable count to the value 10.

    • Example (Setting a variable to an array):

      array = ["hello", "world"]

      or

      array = [
        "hello",
        "world"
      ]

      This sets the variable array to the value ["hello", "world"].

    • Example (Setting a variable to an object):

      array = {"hello":"world"}

      or

      array = {
        "hello":"world"
      }

      This sets the variable array to the value ["hello", "world"].

  • variable,variable = array:

    • Description: Sets a group of variables to an array's contents.

    • Example:

      array = [
        "item1",
        "item2"
      ]
      
      var1,var2 = array

      This sets var1 to "item1" and var2 to "item2"

      array = [
        "item1",
        "item2",
        "item3"
      ]
      
      var1,var2 = array

      This will also work, aswell as any other variable assigment.

    • Example (Embedded assigment):

      array = [
        "item1",
        "item2",
        "item3"
      ]
      
      array2 = [
        "otheritem1",
        "otheritem2"
      ]
      
      array2[1],array2[2],var = array

      This both sets array2's first and second item while setting var to "item3"

List Item Assignment:

  • list.[itemnumber] = "assign-data":

    • Description: Sets the selected item of a list (specified by [itemnumber]) to the inputted data ("assign-data").
    • Example:
      mylist.[3] = "new_value"
      This sets the third item in the list mylist to the value "new_value".
  • list[itemnumber] = "assign-data":

    • Description: Same functionality as list.[itemnumber].
    • Example:
      mylist[3] = "new_value"
      This sets the third item in the list mylist to the value "new_value".

JSON Object Key Assignment:

  • object.key("key") = "assign-data":

    • Description: Sets the selected key of a JSON object (specified by "key") to the inputted data ("assign-data").
    • Example:
      myobject.key("name") = "John"
      This sets the value associated with the key "name" in the JSON object myobject to "John".
  • object.key = "assign-data":

    • Description: Sets the selected key of a JSON object (specified by key) to the inputted data ("assign-data").
    • Example:
      myobject.name = "John"
      This sets the value associated with the key name in the JSON object myobject to "John".
  • object."key" = "assign-data":

    • Description: Sets the selected key of a JSON object (specified by "key") to the inputted data ("assign-data").
    • Example:
      myobject."name" = "John"
      This sets the value associated with the key "name" in the JSON object myobject to "John".
  • object.["key"] = "assign-data":

    • Description: Sets the selected key of a JSON object (specified by "key") to the inputted data ("assign-data").
    • Example:
      myobject.["name"] = "John"
      This sets the value associated with the key "name" in the JSON object myobject to "John".
  • object["key"] = "assign-data":

    • Description: Sets the selected key of a JSON object (specified by "key") to the inputted data ("assign-data").
    • Example:
      myobject["name"] = "John"
      This sets the value associated with the key "name" in the JSON object myobject to "John".

Arithmetic Modifiers:

  • variable += 10:

    • Description: Appends ten to the end of a string or adds ten to a number data type.
    • Example:
      count += 5
      This increments the value of the variable count by 5.
  • variable *= 5:

    • Description: Sets the variable to itself multiplied by 5. This operation works only on number data types.
    • Example:
      total *= 2
      This doubles the value of the variable total.
  • variable /= 5:

    • Description: Sets the variable to itself divided by 5. This operation works only on number data types.
    • Example:
      price /= 2
      This halves the value of the variable price.
  • variable -= 5:

    • Description: Sets the variable to itself minus 5. This operation works only on number data types.
    • Example:
      balance -= 10
      This subtracts 10 from the value of the variable balance.
  • variable %= 5:

    • Description: Sets the variable to itself mod 5. This operation works only on number data types.
    • Example:
      balance %= 10
      This does a modulus calculation on the value of balance.

These commands and modifiers enable you to manipulate variables, lists, and JSON objects, performing assignments and arithmetic operations as needed in your script.

originOS Wiki

Wiki Views:
:views

OSL | RSH | ICN

Clone this wiki locally