FileFactory by WhiteWind script language documentation

# General syntax:

If you used to use Winamp 5 or foobar2000 title formatting you will understand this fast.
There are following syntax elements:

- `Simple text` - Output as is, except that line breaks ignored.
- `'Quoted )(%$ text'` - Output as is, without any formatting. If you want to insert single quote, you should repeat it twice if you already in quotes, and four times if you are not.
- `%Variable%` - Outputs value of variable. The variable name is trimmed, so `% var %` is equal to `%var%`.
- `$function(param)` - Executes function, and returns result. Function name must allways end with bracket, even it have no parameters. Function parameters is also trimmed.
- `//comment` - Any text from // to the end of line is ignored.

## Types conversion:

String transformes into integer by folowing rules:
If string starts with digit or '$' then it conerts into corresponding integer, else it converts into 0. If string starts with '$' then number i treats as hexademical.
Examples:
`$Num(10)=10
$Num(20px)=20
$Num(text)=0
$Num('$F')=15
$Num('$Back')=2988 //$BAC - hexademical number, 'k' is ignored`

String transformes into boolean by folowing rules:
All leading and trailing spaces are trimmed. If string is empty, equals '0' or 'null' then result is TRUE, else result is FALSE.

## Variables:

%FileName% | Name of current file relative to %BaseDir%.
%FileContent% | File content. WARNING - very slow!
%BaseDir% | Base directory of files. Undefined, when list of files loaded.
%R<n>% | RegEx submatch number <n> (0 means whole expression).
%<n>% | Search&Replace RegEx submatch, has effect only in "Replace with".
%FileNumber% | Contains number of current file.

## String functions:

$ChangeFileExt(FileName, Ext: str) | Changes the extension of the FileName to the Ext. Ext specifies the new extension, including the initial dot character.
$Char(x,y...: int) | Inserts ASCII characters. e.g. $Char(13,10) is equivalent to $crlf().
$crlf() | Inserts line break.
$cr() | Inserts ASCII symbol 13.
$lf() | Inserts ASCII symbol 10.
$FileExt(FileName: str) | Extracts extension from FileName including initial dot character.
$FileName(FileName: str) | Extracts name of file (without path and extension).
$FilePath(FileName: str) | Extracts path from FileName. Result ends with '\' or ':'.
$Hex(x:int; y:int=0) | Converts integral number x from decimal to hexdecimal notation, pads with zeros to y digits.
$Num(Num, Digits: int = 1) | Returns Num as decimal number and pads with zeros up to Digits characters (useful for counters). If Digits parameter is ommited then assumed that it equals one.
$RegEx(RegEx, InputStr: str) | Executes regular expression on InputStr, returns found text or empty string if not found.
$RegExs(RegEx, InputStr: str) | Executes regular expression on InputStr, allways returns empty string.
$RegExNext() | Executes last regular expression on last InputStr again, returns found text or empty string if not found.
$RegExNexts() | Executes last regular expression on last InputStr again, allways returns empty string.
$StrCmp(x,y: str) | Compares two strings, case-sensitive. For use with $if()-type functions and other logical operators.
$StrICmp(x,y: str) | Compares two strings, non-case-sensitive. For use with $if()-type functions and other logical operators.
$Trim(x: str) | Removes leading/trailing spaces and not printable characters from a.

## Arithmetic functions:

$Add(x,y...: int) | Adds multiple integral numbers (x+y+...). Accepts any amount of parameters.
$Div(x,y: int) | Divides integral number x by integral number y.
$Mod(x,y: int) | Calculates remainder of x divided by y.
$Mul(x,y...: int) | Multiplies integral numbers (x*y*...). Accepts any amount of parameters.
$MulDiv(x,y,z: int) | Multiplies integral numbers x by y, then divides by integral number z.
$Sub(x,y: int) | Subtracts integral number y from integral number x.

## Logical functions:

$And(x,y...: bool) | Performs logical AND operation on parameters. For use with $if()-type functions and other logical operators.
$If(Condition: bool; ExprTrue, ExprFalse: str) | If Condition is true, executes/returns ExprTrue, otherwise executes/returns ExprFalse.
$If2(Expr, ExprFalse: str) | Same as $if(Expr,Expr,ExprFalse).
$If3(a,...) | Returns first of items being true/non-empty.
$IfGreater(a,b: int; ExprTrue, ExprFalse: str) | If number a is greater than number b, executes/returns ExprTrue, otherwise executes/returns ExprFalse.
$IfLonger(a: str; b: int; ExprTrue, ExprFalse: str) | If string a is longer than b characters, executes/returns ExprTrue, otherwise executes/returns ExprFalse.
$Not(x: bool) | Performs logical NOT operation on parameter. For use with $if()-type functions and other logical operators.
$Or(x,y...: bool) | Performs logical OR operation on parameters. For use with $if()-type functions and other logical operators.
$While(Condition: bool; Action: str) | Repeatedly executes Action while Condition is true/non-empty
$Xor(x,y: bool) | Performs logical XOR operation on parameters. For use with $if()-type functions and other logical operators.

## Variable functions:

$Put(Name, Value: str) | Sets variable named to and returns .
$Puts(Name, Value: str) | Sets variable named to and returns empty string.
$Var(Name: str) | Returns value of variable . Works also for built-in variables and content plugins.