Difference between revisions of "LavishScript:Script Syntax"
Line 3: | Line 3: | ||
=== Preprocessor Directives === | === 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. | + | 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 ==== | ||
* #include "filename" | * #include "filename" | ||
+ | |||
+ | (see [[LavishScript:PreProcessor|PreProcessor]]) | ||
=== Preprocessor Macros === | === Preprocessor Macros === |
Revision as of 05:54, 28 March 2005
Contents
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 }