Goto http://www.stucuk.netGoto http://www.atlanticaonlinewiki.comGoto http://www.game-requirements.com

SAIL Syntax

From Original War Support Wiki

Jump to: navigation, search

Tutorials -> SAIL Syntax

SAIL Syntax

Contents

Intro

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.

Starting

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;

Export

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)

Varibles:

Export MyVarible;
Export MyVarible2,MyVarible3;

Functions:

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.

Declaring Varibles

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;

Functions

In SAIL you use a Function for Procedures as well as Functions. Functions can recieve parameters and have a result sent back out.

No Parameters:

Function MyFunction;
begin
 //
end;

Parameters:

Function MyFuction(AVarible);
begin
 //
end;

Result:

Function MyFunction(AVarible);
begin
 Result := AVarible;
end;
AVarible2 := MyFunction(5);

Comments

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

If Then

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 End

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;

Case

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;
Personal tools
Clanbase
This is a cached copy of the requested page, and may not be up to date.

Sorry! This site is experiencing technical difficulties.
Try waiting a few minutes and reloading.

(Cannot contact the database server: MySQL functions missing, have you compiled PHP with the --with-mysql option? )


You can try searching via Google in the meantime.
Note that their indexes of our content may be out of date.