-
-
Notifications
You must be signed in to change notification settings - Fork 24
OSL ‐ Operators and Expressions
In originOS scripting, mathematical equations play a crucial role in creating dynamic systems and performing calculations. These equations involve operators and comparisons that allow you to manipulate data and make decisions based on conditions. Here's a comprehensive guide to mathematical equations in OSL:
Mathematical expressions are evaluated based on the given operators and data. For example:
if true and false (
When parsed, it becomes:
if false (
The and statement replaces true and false with false, demonstrating how expressions can be dynamically altered.
The general syntax for mathematical equations in OSL is:
data (operator) data2
- (If both data are integers) Adds the number on the right and left together.
- (If either data is not an integer) Joins the right and left with a space in-between.
- (If data on the left is an array) Appends data on the right to the array.
Example:
result = 5 + 3 // result is 8
text_result = "hello" + "world" // text_result is "hello world"
array_result = ["apple"] + ["orange"] // array_result is ["apple", "orange"]
- (If both data are arrays) Concatenates the two arrays together.
- (Else) Joins the two sides together with no spaces.
Example:
array_result = ["hello"] ++ ["world"] // array_result is ["hello", "world"]
text_result = "hello" ++ "world" // text_result is "helloworld"
- Takes the number on the right away from the number on the left.
Example:
result = 8 - 3 // result is 5
- Divides the number on the left by the number on the right.
Example:
result = 10 / 2 // result is 5
- (If the data on the left is a number) Multiplies the number on the left and right together.
- (If the data on the left is text) Repeats the text by the number on the right.
Example:
result = 5 * 3 // result is 15
text_result = "hello" * 3 // text_result is "hellohellohello"
- Runs modulus on the left number using the right number.
Example:
result = 10 % 3 // result is 1
- Runs an exponential on the left number.
Example:
result = 2 ^ 3 // result is 8
- True if both sides are the same (not case sensitive).
Example:
if "apple" == "Apple" (
// This block will be executed because the comparison is not case-sensitive.
)
- True if both sides aren't the same (not case sensitive).
Example:
if "apple" != "orange" (
// This block will be executed because the strings are not the same.
)
- True if both sides are the same (case-sensitive).
Example:
if "apple" === "apple" (
// This block will be executed because the strings are the same in a case-sensitive manner.
)
- True if the number on the left is bigger than the one on the right.
Example:
if 10 > 5 (
// This block will be executed because 10 is greater than 5.
)
- True if the number on the right is bigger than the one on the left.
Example:
if 5 < 10 (
// This block will be executed because 10 is greater than 5.
)
- True if the number on the left is bigger than or equal to the one on the right.
Example:
if 10 >= 10 (
// This block will be executed because 10 is equal to 10.
)
- True if the number on the right is bigger than or equal to the one on the left.
Example:
if 10 <= 20 (
// This block will be executed because 20 is greater than or equal to 10.
)
- True Examples:
true and true. - False Examples:
false and true,true and false,false and false.
Example:
if true and ( 3 > 2 ) (
// This block will be executed because both conditions are true.
)
- True Examples:
true or true,false or true,true or false. - False Examples:
false or false.
Example:
if false or ( 5 == 5 ) (
// This block will be executed because at least one condition is true.
)
- True Examples:
true xor false,false xor true. - False Examples:
true xor true,false xor false.
Example:
if true xor ( 5 < 3 ) (
// This block will be executed because one condition is true and the other is false.
)
- True Examples:
false and false. - False Examples:
false and true,true and false,true and true.
Example:
if false nor ( 2 != 2 ) (
// This block will be executed because both conditions are false.
)
These mathematical equations and boolean expressions provide a powerful toolkit for creating dynamic and responsive behavior in originOS applications. Choose the appropriate operators and comparisons based on your specific needs and desired outcomes.
originOS is a web desktop gui with a self contained file system, programming languages, internet system and a whole lot of stuff an os should be able to do Use originOS here