In order to add new script to the UMX, you must to place corresponding
file into /Scripts directory located int UMX installation path.
File must have *.s extension and must contain following structure:
@SCRIPT <scriptname>
@LANG <langid>
<script definition>
You can place two or more script definitions in the same file.
<scriptname> - is the unique script name, it will appear in The Bat
with prefix 'FN', for example, if you have defining script 'TEST', you
can place it in your template as 'FNTEST'.
<langid> - is the language identifier, following values are: JS for
Jscript, VB for VBscript, PAS for pascal.
<script definition> contains script syntax constructions according
language defined in @LANG
For example, @SCRIPT TEST defines script named "TEST".
After @SCRIPT, the script body follows. Script can be a simple math expression (like TEST1) or a Pascal-like function definition without function header (like TEST2)
@SCRIPT TEST1
@LANG PAS
//Our first script
'Hello Word! Time is '+datetimetostr(now);
@SCRIPT TEST2
@LANG PAS
//Our second script
var time:TDateTime;
begin
time:=now;
Result:='Hello Word! Time is '+datetimetostr(time);
end;
To call your macro from a template, you must use a special autogenerated macro %FNxxxxxxx.
For example, to call script TEST2 you must add %FNTEST2 to your template.
You can use some standard procedures, functions and types exported from Delphi units: System, SysUtils, Windows
To use internal UMC variables, you must add the prefix umc_ before name of variable like this:
@SCRIPT TEST3
@LANG PAS
'UMC version is '+umc_ver
You can use these control statements: for..to, while..do, repeat..until, if...then...else, case...of...end and some similar
@SCRIPT TEST4
@LANG PAS
var i:integer;
begin
result:='';
for i:=32 to 255 do
result:=result+chr(i);
end;
@SCRIPT TEST5
@LANG PAS
var i:integer;
begin
result:='';
i:=32;
while i<=255 do begin
if (i<45)or(i>53) then
result:=result+chr(i);
i:=i+1;
end;
end;
To access the macro parameters , you should use ParamCount and ParamStr functions (similar to the same Pascal functions)
@SCRIPT PARAMETERCOUNT
@LANG PAS
'Parameter count: '+inttostr(ParamCount)
@SCRIPT PARAMETERLIST
@LANG PAS
var i:integer;
begin
result:='';
for i:=1 to paramcount do result:=nl+inttostr(i)+'. '+paramstr(i);
end; |