From Stealth Client

Jump to: navigation, search

Pascal

Pascal Script - a programming language that allows you to write scripts for the Stealth.

The script is a program which implements an algorithm (a sequence of actions) consisting of the required number of conditional operators and comparison operators as well as function calls.

usefull forum topics:

embedded code editor/debugger available.

What is Pascal Script can do

Modules (Uses)

Using the modules, you can break the code into separate parts, and use these parts in several scripts. A software module (unit) is a set of constants, variables, procedures and functions that can be shared by multiple scripts. Each module is similar to a separate program in Pascal: it can have a basic body, which is called before running your program and performs the necessary initialization.

Module skeleton:

unit <identifier>;
 
implementation
uses <modules_list>;    { optional }
{ local descriptions }
{ implementation of procedures and functions }
begin
  { initialization code }
end.


Usage Example

//main script:
program test; 
uses Unit1; 
 
BEGIN 
AddToSystemJournal(MergeStrings('Hello', 'World!')); 
END.
//module Unit1.pas:
unit Unit1; 
 
interface 
 
function MergeStrings(S1: string; S2: string): string; 
 
implementation 
 
function MergeStrings(S1: string; S2: string): string; 
begin 
Result := S1 + ' ' + S2; 
end; 
 
end.

It is worth paying attention to these things:

  • Uses Unit1; - the extension is not written here. can be used as a file without extension and with the extension. pas. extension of ". sc" is not used deliberately, because it is full paskalnye files, not script modules.
  • Filename (without extension) and the title of a unit - the first line (unit Unit1 ;) be the same.
  • Modules should be located close to the script file
  • The module can be a block begin-end, ie it can be self-contained and do not necessarily call some of the main script (just enough to connect it to the script via the main uses)
  • With multiple uses, such as:
//script:
program test; 
uses Unit1,Unit2; 
 
BEGIN 
AddToSystemJournal(MergeStrings('Hello', 'World!')); 
END.
//module:
unit Unit1; 
 
uses Unit2; 
 
interface 
 
function MergeStrings(S1: string; S2: string): string; 
 
implementation 
 
function MergeStrings(S1: string; S2: string): string; 
begin 
Result := S1 + ' ' + S2; 
end; 
 
end.

Unit2 will be included only once. for comparison - using the contents of the file inklyuda would insert into the script two times and would have been a mistake.