Elementary vs. Expression vs. Normal

Elementary Commands

PCC supports a number of Elementary Commands. Those statements often control execution of other statements, like the If conditional statements, or cause them to be executed repeatedly, like the For loop. Elementary Commands often have a special syntax, and special rules how to evaluate their parameters.

See Elementary Commands for a list of all Elementary Commands.

Expression Statement

An expression statement consists of an expression on a line by itself. The expression is evaluated and its result discarded. The expression therefore normally is an assignment operation, such as

 a := Ship(10).Loc.X

which is evaluated for its side-effect of changing the value of the variable a.

If the outermost operator is an equality comparison, as in

 a = Ship(10).Loc.X

PCC automatically converts that into an assignment, because treating it as a comparison and discarding the result would be pointless.

If the expression starts with a keyword that also is an Elementary Command, it is interpreted as that Elementary Command (this applies to Dim and If, which can be commands or function calls). If you really want it as an expression, wrap it into parentheses.

Regular Commands

A regular command has the form

 NameOfCommand FirstParameter, SecondParameter, ...

The parameters are evaluated and then passed to the command.

There are a number of Global Commands. You can add your own global commands by defining subroutines using the Sub command. Many contexts provide object-specific commands that manipulate that object.

Multi-line vs. Single-line

Most commands are single-line commands, i.e. occupy just one line. Such commands can be entered on the Console, for example.

Some Elementary Command are complex enough to need multiple lines. For example, an If/Then/Else statement might look like this:

 If Owner$=My.Race$ Then
   NewCircle Loc.X, Loc.Y, 10
 Else
   NewRectangle Loc.X-10, Loc.Y-10, Loc.X+10, Loc.Y+10
 EndIf

As a general rule, a command that starts as a single-line command cannot continue as a multi-line command. This is invalid:

 ForEach Ship Do If Owner$=My.Race$ Then
   Print Name
 EndIf

It must be written as

 ForEach Ship Do
   If Owner$=My.Race$ Then
     Print Name
   EndIf
 Next

Multi-line commands can only be used within scripts. You cannot define your own multi-line commands.

This is a testing version.
It may be incomplete, and have more bugs (or features) than the public live version at planetscentral.com.