Skip to content

SuperMacro - Functions#

Syntax#

Note

Use a : between the command name and the arguments

{{FUNC:NameOfFunction:OutputVariable:InputParam1:InputParam2:InputParam3...}}

Where InputParamX can either be text (10) or another variable ($MyVar)

Drill-Down of syntax:

  1. All functions always start with the FUNC keyword.
  2. The 2nd argument would be the name of the function (see column 1 in table below).
  3. The 3rd argument would be the return variable (i.e. the variable which will hold the result of the function). Note: No $ is needed here.
  4. Arguments 4 and up are the input needed for the function. Each function has a different number of Input arguments (as stated in column 2 in the table below).

    Note

    To differentiate between regular text and variables, start with a $ if you're referring to a variable

Supported Functions#

Math Functions#

Function Name Number of Input arguments Example Comments
ADD 2 {{FUNC:ADD:MyVar:10:20}} (10+20 and store in MyVar)
{{FUNC:ADD:Var1:10:$Var2}} (Add 10 to Var2 and store in Var1)
{{FUNC:ADD:Result:$Var1:$Var2}} (Sum Var1 and Var2 and store in Result)
SUB 2 {{FUNC:SUB:MyVar:20:10}} (20-10 and store in MyVar) (Additional examples similar to ADD above)
MUL 2 {{FUNC:MUL:MyVar:10:20}} (10*20 and store in MyVar) (Additional examples similar to ADD above)
DIV 2 {{FUNC:DIV:MyVar:​100:50}} (100/50 and store in MyVar). (Additional examples similar to ADD above)
ROUND 1 {{FUNC:ROUND:MyVar:10,11:2}}Rounds a value to the specified number of fractional digits
RANDOM 2 {{FUNC:RANDOM:MyVar:1:20}} (Find a random number between 1 (inclusive) and 20 (exclusive) and store in MyVar.
{{FUNC:RANDOM:MyVar:$FirstVal:$SecondVal}} (Find a random number between FirstVal variable (inclusive) and SecondVal variable (exclusive) and store in MyVar.
Note: First value must be LOWER than Second value.
NOW 1 {{FUNC:NOW:MyVar:yyyy-MM-dd HH:mm:ss}}
MyVar will have the current date and time.
FLOOR 1 Returns the largest integral value less than or equal to the specified number
{{FUNC:FLOOR:num:3.1415}} => num contains 3
CEILING 1 Returns the smallest integral value greater than or equal to the specified number
{{FUNC:CEILING:num:3.1415}} => num contains 4
MIN 2 Returns the smaller of two numbers
{{FUNC:MIN:num:-100:100}} => num contains -100
MAX 2 Returns the larger of two numbers
{{FUNC:MAX:num:-100:100}} => num contains 100
ABS 1 Returns the absolute value of a specified number
{{FUNC:ABS:num:-100}} => num contains 100

String Functions#

Function Name Number of Input arguments Example Comments
CONCAT Unlimited {{FUNC:CONCAT:MyVar:Hello:World:$Var1:Hi:$Var2}}
MyVar will have the string: HelloWorldXXXXHiYYYY Where XXXX is the contents of Var1 and YYYY is the contents of Var2
REPLACE 3 {{FUNC:REPLACE:MyVar:Hello:He:Y}}
MyVar will have the string: Yllo
{{VARSET:XX:Hello World}} {{VARSET:A:l}}{{VARSET:B:Z}} {{FUNC:REPLACE:MyVar:$XX:$A:$B}}
MyVar will have the string: HeZZo WorZd
LEN 1 {{FUNC:LEN:MyVar:Hello World}} (Length of the string 'Hello World')
MyVar will have the value 11
MID 2 (Arguments: 1. 0-Based Start Position 2. [Optional] Length)
{{FUNC:MID:RES:Hello:2}} RES will have llo
{{FUNC:MID:RES:Hello:0:2}} RES will have He
REVERSE 1 {{FUNC:REVERSE:MyVar:Hello World}}
MyVar will have the value: dlroW olleH
INDEXOF 2 Returns the first 0-based position of a text in the string.
{{FUNC:INDEXOF:RES:Hello:e}} will return 1 into RES (since e has an index of 1 in the string)
UPPERCASE 1 {{FUNC:UPPERCASE:MyVar:HeLlO woRlD}}
MyVar will have the string: HELLO WORLD
LOWERCASE 1 {{FUNC:LOWERCASE:MyVar:HeLlO woRlD}}
MyVar will have the string: hello world
TITLECASE 1 {{FUNC:TITLECASE:MyVar:HeLlO woRlD}}
MyVar will have the string: Hello World

Date Time Functions#

Hint

Negative values will calculate Date/Time Functions backwards.

Function Name Number of Input arguments Example Comments
AddDays 3 {{FUNC:NOW:today:yyyy-MM-dd}}
{{FUNC:AddDays:yesterday:$today:-1}}
{{SetClipboard:$yesterday}}
{{ctrl}{v}}
Prints yesterdays date from clipboard using an existing datetime.
AddMonths 3 {{FUNC:AddMonths:lastmonth:$today:-1}} Counts one month back from an existing datetime and saves to a new var.
AddSeconds 3 {{FUNC:AddSeconds:125secondsfromnow:$today:125}} Add 125 seconds to an existing datetime and saves to a new var.
AddMinutes 3 {{FUNC:AddMonths:65minutes:$today:65}} Add 65 minutes to an existing datetime and saves to a new var.)
AddHours 3 {{FUNC:AddMonths:20hours:$today:20}} Add 20 hours to an existing datetime and saves to a new var.
DateDif 4 {{FUNC:DATEDIFF:RES:$date1:$date2:d}} Compares two datetimes and return the time difference between them (result can be in days/hours/minutes/seconds/miliseconds)
DateFormat 4 {{FUNC:DATEFORMAT:RES:$date1:dd/MM/yyyy HH:mm:ss}} Allows to format a date

Other functions#

Function Format Example Comments
EXEC {{EXEC:FILENAME|RUNASADMIN|ARGUMENTS}} {{EXEC:C:\WINDOWS\NOTEPAD.EXE|0|C:\myfile.txt}} Can also be used to load websites. {{EXEC:https://docs.barraider.com}}