MyChat Scripting Language (or MSL) resembles to classical Pascal programming language by its semantics. Default scheme of any script looks like this:


program TestScript;
begin
end.


program —  is a service unnecessary word, begin..end — bracket operators. The dot at the end of the script symbolizes the end of the program.

 

All language operators are separated by a semicolon, the letter case does not matter. Variables should be described in advance and have a defined type. The name can contain small and capital letters, numbers and underscores. Variable names can't begin with a number and contain spaces. For example:


program Variables;
var
  st: string;
  x, y: integer;
begin
  x := 100;
  y := 150;
  st := inttostr(x + y);
end.


In this program, 3 variables are shown: one string and two integers, and then the sum of "x" and "y" is assigned to the "st" textual variable. Notice, that it was necessary to use the function to convert a number to a string since MSl strictly controls the data types transformation.

 

MSL supports three types of cycles:

 

1.Iterative:


for i := 1 to 100 do begin
end;


2.With a precondition:


while x > 100 do begin
end;


3.With a postcondition:


repeat
until r = false;


There are also conditional operator and "case" operator:


if (x = 10) and (StrToInt(test) < 100) then begin
end;


A string variable can't be used in a "case" operator:


case z of
  1: begin 
    x := 100;
    y := 200;
  end;
  2: x := 700;
  3: y := 10000;
  else x := 0;
end;


Finally, a subprogramme mechanism is supported (procedures and functions). The function differs from the procedure. The function returns its work result in the name, as a constant. You can pass parameters by a reference and value into procedures and functions. If the "var" reserved word (in function parameters) is located in front of a variable, then you can change a variable in the function, then it changes in the program where this function is called from. If there is no the "var" reserved word, you can do whatever you want with this variable because the transferred variable does not change in the main program.


procedure Test(x, y: integer; var st: string);
begin
  st := IntToStr(x * y);
end;
function Fact(n: integer): integer;
var 
  i, x: integer;
begin
  x := 1;
  
    for i := 1 to n do x := x * i;
    
  result := x;
end;


Comments in source texts

Composite record data types

Working with fractional numbers

 

For more detailed information about the language and its usage we recommend you to check procedures and functions work examples.

 

Also, you can find the examples of scripting language usage on the official forum in the "Bots, plug-ins, scripts etc." section.