Инструменты пользователя

Инструменты сайта


en:tcmediainfo:documentation:scripts

Overview

Writing scripts will allow fully change info output for your needs. Plugin use scripting engine with simplified Pascal-like syntax.

But important to remember, that complex scripts will slow down plugin work.

Data types

All variables are stored as variants. This meant that usually you can use them without additional type conversions. However in some cases explicit type casting can be required, this can be done with functions Integer, Number and String.

Also it's possible to use in expressions True and False constants.

Variables

It's no need to declare variables (except arrays), they are creates dynamically on first assignment. Variable type depends on the last value assigned, type checking is not carried out. So, if you assign string to numeric variable it's type will be changed.

Operations

Arithmetic+, -, *, /, ^ (power), SHL, SHR
Bitwise operationsBITOR,BITAND,BITXOR,BITNOT
Logical>, <, >=, ⇐, =, <>, AND, OR, NOT

Operators precedence standard, you can use parentheses.

Blocks

Blocks are used where need to execute few different statements.

begin
 ...
end;

Conditions

Simple condition. Chaecks <expression> result, if True, the <statement1> is executed, if False - <statement2> executed.

if <expression> then
 <statement1>
else
 <statement2>;

Switch condition. Checks <expression> result for defined values. Can have else for all values not defined explicitly.

case <expression> 
 <value1>[,<value2>[, <valueN>]]:
   <statement1>;
 <value1>[..<value2>]:
   <statement2>;
 else 
   <statement3>;
end;

Loops

Loop execute <statement> from <value1> to <value2>, with step 1.

for <value1>:=<expression> to <value2> do
 <statement>;

Loop execute <statement> from <value1> to <value2>, with step -1.

for <value1>:=<expression> downto <value2> do
 <statement>;

Loop execute <statement> while <expression> is true.

while <expression> do
 <statement>;

Loop execute <statement> until <expression> is become true.

repeat
 <statement>;
until <expression>;

Other operators

Continue loop. Can be used in loops only.

continue;

Break the loop. Can be used in loops only.

break;

Exit from procedure or function. When calling while in main script, terminate script.

exit;

Go to label. In current time it's not recommend to use this operator in order to keep code understandable.

label <name>;
...
goto <name>;

User procedures and functions

Procedures and functions (in sense of the subroutines on interpreter language) are supported. The function heading specifies only names of formal parameters, without parameters types and pass method (var or value). Also, function's result types are not declared. To return function result you should assign value to variable «result».

If actual parameter is variable (not expression), it considered as var-parameter. In this case assigning new value to this parameter inside procedure or function will affect the actual parameter variable.

At the same time, all interpreter global variables inside a function or procedures looks like local variables, with the same initial values as global ones. You can change this values inside procedures (functions), but it's don't affect the global variables. All new variables created inside procedures and functions are local, and will be destroyed after exiting. Therefore, it is possible to use any names for local variables, without conflicts with the global variables.

Procedures are not return values:

MyProc([<expression1>[, <expressionN>]]);
 
procedure MyProc([<value1>[, <valueN>]]);
begin
...
end;

Functions return values in special result variable:

<value>:=MyFunc([<expression1>[, <expressionN>]]);
 
procedure MyFunc([<value1>[, <valueN>]]);
begin
...
result=<expression>;
end;

Function libraries

You can use function libraries, that can be loaded with uses and include operators.

uses only loads procedures and functions declarations that can be used in other scripts. The most common scenario.

uses "LibName";

include inserts text into the script from node funclib with given name,

include "LibName";
en/tcmediainfo/documentation/scripts.txt · Последние изменения: 2019/02/21 16:59 — loopback

Инструменты страницы