From Original War Support Wiki
Tutorials -> SAIL Syntax
SAIL Syntax was based on Pascal's but differs in places. The following is designed to give you the basic Syntax knowlage of SAIL. Note that all of the Syntax code must be in English (I.E Begin, End, For, Case, Function) but names of varibles and function names can be anything.
The starting block can only be used once. It is where the first bit of SAIL code will be ran and is normaly used to setup the map.
Starting Begin Wait(1000); End;
To allow other Module`s to access Functions and Varibles from a Module you need to use an Export. (each 'page' of code is called a module)
Export MyVarible; Export MyVarible2,MyVarible3;
Export Function MyFunction; begin // end;
Exported things are called and used just the same as normal ones. The only difference is that there globaly open to every Module.
If you do not want ur varible to be global you need to use Var to declare varibles. In SAIL Varibles don't have a type, they can be anything.
Var MyVarible; Var MyVarible2,MyVarible3;
Function MyFunction; Var MyVarible; begin // end;
In SAIL you use a Function for Procedures as well as Functions. Functions can recieve parameters and have a result sent back out.
Function MyFunction; begin // end;
Function MyFuction(AVarible); begin // end;
Function MyFunction(AVarible); begin Result := AVarible; end;
AVarible2 := MyFunction(5);
You can add comments to your code by simpaly typing // . Anything after the // is considered as a comment.
Wait(10); // A Comment Wait(10); // A Comment // Wait(10); <---- is considered a comment
The if then allows you to see if a varible or functions result equals or differs from a varible or constant value.
If AVarible = 5 then Wait(1);
If AVarible = AVarible2 then Wait(1);
If Query("Q1") = 1 then Wait(1);
If then commands can also have Else's
if AVarible = 1 then Wait(1) else Wait(2);
Begin and end group a bunch of code together, they are generaly used after other Syntax commands like For Loops, If Then's, etc.
if AVarible = 1 then begin Wait(1); Wait(2); end;
For Do Loop
For loops repeat the line below it from X to X.
For x := 1 to 5 do wait(1);
For x := 1 to 5 do begin wait(1); end;
y := 1; j := 5; For x := y to j do begin wait(1); end;
Repeat Until Loop
Repeat Until loops run the same code over and over until a condition is met.
x := 0; Repeat x := x + 1; Until x := 5;
While Do Loop
While loops are the same as Repeat Untils except the condition comes first.
x := 0; While x < 5 do begin x := x + 1; end;
The case command allows you to simpily make it run code depending on the value of a Varible or the result of a function.
case Query('Q1') of 1:begin // some code that will get executed if the result of the query is 1 end; 2:begin // end; end;
case AVarible of 1:begin // end; 2:begin // end; end;
Insted of using values you can use constants too.
case AVarible of unit_human:begin // unit_human is a predefined constant in OW. Using it, you can easily check if a specified unit is a soldier end; unit_vehicle:begin // end; end;