Set Command
Let's continue discussing variables and arithmetic expressions. There is no variable declaration in ObjectScript. Variable names are case-sensitive. You use Set to assign a value to a variable. The value can be a simple string or number, or it can be an expression. Variables can hold up to 3,641,144 characters. Set can also assign the same value to several variables at the same time.
USER>set x = 4 + 2
USER>write x
6
USER>set y = "Tutorial" write y
Tutorial
USER>set (a, b, c) = 4
USER>write a, " ", b, " ", c
4 4 4
USER>
ObjectScript uses seven binary arithmetic operators. The first two are also unary operators.
Operator | Operation | Example (Results) |
---|---|---|
+ |
|
set x = 4 + 2 (x = 6) set z = "546-FRJ" set y = +z (y = 546) |
- |
|
set x = 4 - 2 (x = 2) set z = "-5 degrees" set y = -z (y = 5) |
* |
|
set x = 4 * 2 (x = 8) |
/ |
|
set x = 5 / 2 (x = 2.5) |
** |
|
set x = 5 ** 2 (x = 25) |
\ |
|
set x = 5 \ 2 (x = 2) |
# |
|
set x = 5 # 2 (x = 1) |