Macros

goboscript has a C-like preprocessor. This allows you to define macros and include files.

!!! note The preprocessor directives start with a `%` character. The `%` character must always appear at the start of a line. There cannot be any indentation before the `%` character.

Include

Include the contents of a file.

%include path/to/file.gs

The `.gs` extension is optional. If not specified, the file extension will be added automatically. (This is recommended)

If the include path is a directory, the file inside the directory with the same name as the directory will be included.

Define

Define a macro. That identifier will be substituted with the subsequent text.

%define macro_name replacement text

Define with arguments

Define a macro with arguments. The arguments will be substituted with the tokens from the callsite.

%define macro_name(arg1, arg2) replacement text

Remove a macro definition

%undef macro_name

Conditional compilation

%if macro_name
    code
%endif
%if not macro_name
    code
%endif

Source