LavishScript:Script Syntax

From Lavish Software Wiki
Jump to navigation Jump to search

Overview

Scripts consist of preprocessor directives, preprocessor macros, comments, functions, code blocks and commands. All scripts must have a function called main.

Preprocessor Directives

Preprocessor directives are things that the script handler should do before the script is executed. This may include replacing certain words with others throughout the script, or adding another file to be read into this script.

Until LavishScript 1.08, the only preprocessor directive handled was #include (This is currently the case for Fury).

#include

  • #include "filename"

(see Preprocessor)

Preprocessor Macros

Preprocessor macros are not yet implemented.

Comments

Comments must be on their own line, never at the end of another line. Any line that starts with a semi-colon is considered a comment, and will not be handled by the script.

Functions

Functions are defined like so:

function MyFunc1()
{
  commands
}
function MyFunc2(parameter1,parameter2,parameter3)
{
  commands
}
function MyFunc3(string parameter1,int parameter2)
{
  commands
}

Functions may have any number of parameters, and each will default to the string type if a type is not given. Each function must have its own code block. The function ends either at the final }, or from a return command. Either way, execution proceeds after the previous call statement, or ends the script if the function is main.

Code Blocks

Code blocks are defined by having a { to begin, and } to end, on their own lines. These blocks are used to define the scope of a function, and are also used by certain commands such as If and While.

Commands

Commands are simply LavishScript commands, as may be entered in a console or command file.

Examples

  • Obligatory "Hello World" script
function main()
{
   echo Hello World
}