UMX knowledge base
This article describes how to create your own macros using scripting technology via UMX.

 

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, to define macros FNTESST returns you 'Hello, World' string, do the following:

Place file TESST.S

@SCRIPT TESST
@LANG JS
hello();
function hello(){
return 'Hello, World';
};

Into /Scripts directory and restart The Bat.

You can optimize this tiny script:

@SCRIPT TESST
@LANG JS
'Hello, World'

It will return you same result.

To use parameters passed to script, you must to use special function GetParams() which initializes two variables: ParamCount and ParamStr. ParamCount will equal to number of parameter passed to script ParamStr[n] - is the array of parameters, first index is 1.
For example, you can list all the parameters passed to script:

@SCRIPT JSPL
@LANG JS
hello();
function hello(){
GetParams();
var i,s;
s='';
for(i=1;i<=ParamCount;i++)s+=i+' - '+ParamStr[i]+'\n';
return s;
};


If you place %FNJSPL('one','two','three') in you template, you will get the following:

1 - one
2 - two
3 - three

It is simply!!!!

At the end, i will show you script allows you to get amount of seconds between tho date-time stamps:

@SCRIPT SECSBETWEEN
@LANG JS
calc();
function calc(){
GetParams();
if(ParamCount<2)return "Wrong number of parameters";
d1=new Date(ParamStr[1]);
d2=new Date(ParamStr[2]);
dt=Math.abs((d1.getTime()-d2.getTime())/1000);
return Math.round(dt);
};


Now, you can write %FNSECSBETWEEN("18/02/1981 14:00:15","25/01/1985 16:00:00")
And you will know that there is 144644385 seconds between these two dates.