Skip to main content

Syntax

So far, you've learned these commands: Do, Return, Quit, Write, Read, and Set. It's time to learn about command syntax in general. The syntax of a command is: command (or its abbreviation), followed by a single space, followed by one or more arguments separated by commas. There can be spaces and line breaks nearly anywhere within the arguments. Commands are not case-sensitive.

You can also place more than one command on a line. There must be at least one space between the last argument of one command and the next command. Certain commands, which you'll learn about later, don't have arguments. If you want to place another command after an argumentless command, it must be followed by at least two spaces. This example below shows several commands with multiple arguments.

ObjectScript also provides many functions, all documented in the ObjectScript Reference. Functions accept arguments within parentheses and return a result. Like commands, functions are not case-sensitive, and can be abbreviated; their names begin with $. The RightTriangle example used $Zsqr to compute the square root. The example below also shows the $Zdateh and $Zdate functions, and the $Horolog system variable (abbreviated as $h). These functions are covered later.

Typically when writing code, you use the full command name. When debugging or testing, you can use the abbreviation, usually a single letter.

Terminal


USER>WrIte "Not case-sensitive"
Not case-sensitive
USER>read !, "DOB: ", dob  set days = $h - $zdateh(dob), today = $zdate(+$h)

DOB: 7/7/1921
USER>write !, "On ", today, ", you are ", days, " days old."

On 12/27/2017, you are 35237 days old.
USER>w "Hello World!"
Hello World!

USER>write $zsqr(63)
7.93725393319377177
USER>
FeedbackOpens in a new tab