Syntax:

It is hard to describe theoretical syntax that why we start from middle, but on examples everything will be clear.


Hello World

Lets start from as from most faumost hello world program now explain line by line what is happaning there.

text = "Hello World!";
frame a { text };
ui|Show(a);
ui|WaitFor("Close");

Line 1 declare variable text as string and assing value "Hello World1".
Line 2 declare a frame variable. Inside frame we put text variable.
Line 3 shows frame on screen.
Line 4 waits till user close application.


Includes

If you want to include another file into you source you can use include preprocesor, like below we include base.i file

#<base.i>

Comments

Maybe not most important but needed in every language - comments. We have two types of them. Multi line starts from /* and ends at */. And single line comments which starts from // and ends at the end of line.

/*Hello World 
  - Your first step to Master this language*/
text = "Hello World!";
frame a { text };  
ui|Show(a);          //Show Frame on screen
ui|WaitFor("Close"); //Wait for close

Separation

As you can see after each statement there is ";" separation. In our example each statement starts from begginign of line but it is not must. This will work also:

text = "Hello World!"; frame a { text }; ui|Show(a); ui|WaitFor("Close");

Variables

You can declare you variable anywhere in source code. You can indicate what type you exacly want as we did in line 1, or just let compilator to figure out which type is it like in line 2. Anywhere in code you can do redeclaration as long type is the same, so line 3 is ok because at line 2 'text' are autodeclared to 'string', but line 4 will fail because before we have declaration of 'name' as string.

string name;                   // Declaration of string variable
text = "Hello World!";         // Declaration and assig of string variable
string text = "Redeclaration"; // Redeclaration will not generate error
int name = 1;                  // Redeclaration will generate error because of line 1
i = i + 1;                     // This will fail as 'i' is not yet declared
i = 0; i = i + 1;              // This will not fail, as we have first declaration

Functions

You can declare function anywhere in source code. First you need to indicate type of function return, then function name, then in the brackets list of parameters (including type) separated by coma, and at the end body of function inside { }. Statement return returns value of function. Below exaple of sum function which add two integers and return result.

int sum(int one,int two) {
  num = one + two;
  return num;
}

You do not need to declare function before you want to use it, you can do this later in code.

four = sum(2,2);

int sum(int one,int two) {
  num = one + two;
  return num;
}

However if you declare it before use, or at least write prototype compilation may be faster but binary code will be the same.

int sum(int one,int two) {
  num = one + two;
  return num;
}

four = sum(2,2);
int sum(int one,int two); //prototype
 
four = sum(2,2);

//declaration
int sum(int one,int two) {
  num = one + two;
  return num;
}

Globals

All variables declared with global prefix are global, visible in all functions in source file.

global int amount = 50;

//amount = 50 here
add(10); 
//amount = 60 here
add(30);
//amount = 90 here
sub(80);
//amount = 10 here


ass(10);
//number = 10 here
mul(10);
//number = 100 here


void add(int num) {
  global int amount;
  amount = amount + num;
}

void sub(int num) {
  global int amount;
  amount = amount - num;
}

Global varialbe can be defined only in function which use it

ass(10);
//number = 10 here
mul(10);
//number = 100 here



void ass(int num) {
  global int number;
  number = num;
}

void mul(int num) {
  global int number;
  number = number - num;
}