Skip to main content

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.

Terminal


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.

Arithmetic Operators
Operator Operation Example (Results)
+
  • Addition.

  • When used in front of an expression as a unary operator, it forces a numeric interpretation of the expression.

set x = 4 + 2 (x = 6)

set z = "546-FRJ"

set y = +z (y = 546)

-
  • Subtraction.

  • When used in front of an expression as a unary operator, it forces a numeric interpretation of the expression, and reverses the sign.

set x = 4 - 2 (x = 2)

set z = "-5 degrees"

set y = -z (y = 5)

*
  • Multiplication.

set x = 4 * 2 (x = 8)
/
  • Division.

set x = 5 / 2 (x = 2.5)
**
  • Exponentiation.

set x = 5 ** 2 (x = 25)
\
  • Integer Division - the integer portion of the result after the first operand is divided by the second.

set x = 5 \ 2 (x = 2)
#
  • Modulo - the remainder after the first operand is divided by the second.

set x = 5 # 2 (x = 1)
FeedbackOpens in a new tab