Directives

Preprocessing directives are unique keywords that alter the compiler's behavior. They start with a dollar sign $ and enclosed within curly braces{}.

$INCLUDE

Allows to insert the content of an external text file in the current file. If the compiler finds this directive it opens the file at the location provided as the parameter and proceeds from the code written in the included file. When it reaches the end of the included file it returns back to the previous file.

Syntax:

{$INCLUDE path\to\file}
{$INCLUDE loadwav.txt}
{$INCLUDE C:\dev\getarrayindex.txt}

If the file path is relative, the compiler scans directories in the following order to find the file:

  1. directory of the file with the directive

  2. data folder for the current edit mode

  3. Sanny Builder root directory

  4. the game directory

If none of these directories contains a requested file the compiler throws an exception.

You may use this directive unlimited number of times. The included files may contain this directive too.

A shorter form of this directive is $I.

$INCLUDE_ONCE

Similar to {$INCLUDE}, with the only difference being that if the code from a file has already been included, it will not be included again, and the directive is silently ignored.

$EXTERNAL

Makes the compiler to treat the file as an external script. Meaning, the resulting output file will be header-less and with relative label offsets, as an .scm file from the script.img. Using this directive requires that the file contains only one script or a single mission.

An alternative way to get such file is the debug option SKIP_SCM_HEADER. This option could be enabled in the console or from the dropdown list on the main toolbar.

Syntax:

{$EXTERNAL}

A shorter form of this directive is $E.

$CLEO

An analogue of the $E one, but the compiler automatically copies an output file to the game\CLEO directory. The file also gets an extension provided as the directive parameter.

Syntax:

{$CLEO <extension>}

extension is an optional parameter specifying the file extension of the output file. It starts with the period character .. If no extension is present, the compiler uses the default value .cs

{$CLEO .cm} // the file gets the extension .cm
{$CLEO} // the file gets the default extension .cs

So this directive is the perfect solution to make a CLEO script.

{$CLEO} also implies {$USE CLEO}

$NOSOURCE

Prohibits the compiler from including a source code of the script.

Without this directive when either the directive $EXTERNAL or $CLEO is present and the option Add extra info to SCM is enabled, Sanny Builder adds the source code into an output file.

Syntax:

{$NOSOURCE}

$OPCODE

Registers a custom opcode via the script.

All the opcodes definitions are contained in a special file, one for each supported game. But sometimes it's necessary to add a custom opcode to use in the current script. $OPCODE makes it possible without touching the INI file.

Syntax:

{$OPCODE <opcode definition>}

or

{$OPCODE <path\to\file>}

or

{$OPCODE}

opcode definition - it accepts an definition in the same format as the INI file.

{$OPCODE 0CCC=1,my_new_opcode %1d%}

path\to\file - this directive also accepts a file name as its parameter. This file must contain only opcodes definitions to be loaded. If a relative path is provided, the compiler scans directories using the same rules as for $INCLUDE.

{$OPCODE additional_opcodes.ini}

When used without any parameter, this directive reloads the original opcodes definitions file and reverts all changes made.

{$OPCODE}

A shorter form of this directive is $O.

$USE

Allows the compiler to use a custom instruction set (an extension).

{$USE CLEO+}

You can enable multiple extensions by separating them with commas.

{$USE ini, bitwise, CLEO+}

$VERSION

This directive is deprecated since v3.1.0

Sets what version of opcodes to use during compilation.

Syntax:

{$VERSION x.y.zzzz}
  • X- edit mode ID

  • y - parameters order

    • 0 - original: 0, 1, 2, etc

    • 1 - custom order, some parameters reordered

  • zzzz - opcodes version

By default the compiler uses the version current_edit_mode.1.0000.

$VERSION_RESTORE

This directive is deprecated since v3.1.0

Restores the version to the value prior to using $VERSION.

Syntax:

{$VERSION_RESTORE}

Last updated