Skip to content

Script Commands

Bashar Astifan edited this page Jan 6, 2022 · 14 revisions

Back to Commander

General Commands

Defines

define: used to define/update new variable

COMMAND STRUCTURE: define [variableName];, variableValue

if the variable already defined will be updated with the new value

You can use value from another variable as ID

EXAMPLE: define [variableName];, [sourceVariableName]

As Commander compiler based on text replacements.. large text could break the script this will help to resolve the issues when your data contains multi lines


set: used to set new value for specific variable

COMMAND STRUCTURE:

set [variableName];, variableValue

IS IT SAME AS define?

No, with set command you can deal with specific values as listed below:

  • ++: set [variableName];, ++
  • --: set [variableName];, --
  • +(varaible or number): set [variableName];, +value
  • -(variable or number): set [variableName];, -value
  • *(variable or number): set [variableName];, *value
  • /(variable or number): set [variableName];, /value
  • any string/numeric value: set [variableName];, value

you can also increase the value directly:

[variableID]++, [variableID]--

If you want to set value from another variable as ID

EXAMPLE:

define [variableName];, [sourceVariableName]

this will help to resolve the issues when you data contains multi lines


func: used to define/update new function

COMMAND STRUCTURE:

func [functionName];, (command)

use call command to invoke the function

EXAMPLE:

func [variableName]{
command1
command2
}

If you want inline syntax, you can define multiple command by split them with !#! or \n

func [variableName];, (command1!#!command2!#!command3)

to call the function use call command:

EXAMPLE: call [functionName]

EXAMPLE (With Parameters): call [variableID]|paramName1:Value|paramName2:Value..etc


call: run commander command from variable

COMMAND STRUCTURE:

call [variableID]

This will solve the issues that could happen because of multiple internal commands

Use definec to define new command with variable

or get the command from file

Please note that call command can be used with sub command

like you can use it with loop, each..etc

You can send custom param to the define command

EXAMPLE:

call [variableID]|paramName1:Value|paramName2:Value..etc


clean/clear: clean all stored variables, storage items, processes, timers..etc

COMMAND STRUCTURE:

clean/clear all

if you want to avoid any conflict or unwanted results use this command at the top of each script



Includes

include: used to include another script into the current one

COMMAND STRUCTURE:

include [fileID]


includel: used to include another script into the current one

COMMAND STRUCTURE:

includel fileLocation

the file should be available in the files storage

you can include any file in the script folder by it's name (for script bundle)

EXAMPLE:

includel extraContent.wutc



Strings

regex: extract string using regex

COMMAND STRUCTURE:

regex [variableID];, pattern;, [targetID]

pattern like:

define [sourceID];, Welcome To (WUT)
regex [testID];, \(.*\);, [sourceID]

testID will be (WUT)

be aware to the special chars \ - ( - < -> and don't forget to add \ before them \ - ( - < - >

if you got any parsing error message then you have special char in your pattern


regexg: extract string using regex with group

COMMAND STRUCTURE:

regexg [variableID];, pattern;, group;, [targetID]

pattern like:

define [sourceID];, Welcome To (WUT)
regexg [testID];, Welcome (?<middle>\w+);, middle;, [sourceID]

testID will be To

as you can see this will return only the requested group

be aware to the special chars \ - ( - < -> and don't forget to add \ before them \ - ( - < - >

if you got any parsing error message then you have special char in your pattern


regexc: extract string collection using regex with group

COMMAND STRUCTURE:

regexc [variableID];, pattern;, group;, [targetID]

pattern like:

define [sourceID];, Welcome To (WUT) Welcome test collection
regexc [testID];, Welcome (?<middle>\w+);, middle;, [sourceID]

testID will be To,test

as you can see this will return only the requested group

be aware to the special chars \ - ( - < -> and don't forget to add \ before them \ - ( - < - >

if you got any parsing error message then you have special char in your pattern


replace: replace content with another content

COMMAND STRUCTURE:

replace [targetID];, original;, replacement

The results will be saved to the same variable

you can replace multiple words at once

replace [targetID];, w1|w2|w3;, r1|r2|3

You can replace multi target with one source:

replace [targetID];, w1|w2|w3;, r1


replaced: replace content with another, then define result

COMMAND STRUCTURE:

replaced [outputVariable];, [targetID];, original;, replacement

outputVariable will be defined by default

multi replace available as in replace command


replacer: replace content with another content using regex

COMMAND STRUCTURE:

replacer [outputVariable];, [targetID];, regex;, replacement

outputVariable will be defined by default

multi replace available as in replace command but use '[#]' separator instead of |


substr: get sub string using start, end index

COMMAND STRUCTURE:

substr [variableID];, [targetID];, startIndex;, endIndex

if you want to set 'end' to the last index use 'last' instead of number


length: get length for string variable

COMMAND STRUCTURE:

length [variableID];, [targetID]



Arrays

Basically Commander array is string value divided by specific char, default is ,

most array commands will give you the option to set the separator char

count: get items count for array variable

COMMAND STRUCTURE:

count [variableID];, [targetID];, separator


subarr: get sub array using start, end index

COMMAND STRUCTURE:

subarr [variableID];, [targetID];, separator;, startIndex;, endIndex

if you want to set 'end' to the last index use 'last' instead of number


unique: delete duplicated values

COMMAND STRUCTURE:

unique [variableID];, [arrayID];, separator

EXAMPLE:

define [arrayID];, "A", "B", "C", "D","A"
unique [cleanArray];, [arrayID];, ,

cleanArray-> "A", "B", "C", "D"

you can use the [arrayID] as string instead of ID, just write the arrayID without []


sort: will sort data by AES, DESC

COMMAND STRUCTURE:

unique [variableID];, [arrayID];, separator;,, sortType

sortType: can be aes or desc

EXAMPLE:

define [arrayID];, "A", "B", "C", "D","A"
unique [cleanArray];, [arrayID];, ,;, aes

cleanArray-> "A","A", "B", "C", "D"

you can use the [arrayID] as string instead of ID, just write the arrayID without []


reformat: merge two values into one

This is very important command for arrays, it will help to build values for any GUI command

COMMAND STRUCTURE:

reformat [variableID];, values1;, values2;, mixSymbol;, separator

EXAMPLE:

define [Values1];, "United State", "United Kingdom", "China"
define [Values2];, "us", "uk", "cn"
reformat [CountriesArray];, Values1;, Values2;, :;, |

CountriesArray -> "United State":"us"|"United Kingdom":"uk"|"China":"cn"

you can use these values into list or combo

if you want to remove " you can call replace command

replace [CountriesArray ];, ";,

then the output will be:

CountriesArray -> United State:us|United Kingdom:uk|China:cn

Note: The command currently work only with values separated with ,

so if your input value using something else use replace command first


Working with index:

How to get specific index from variable?

if you sure that your variable contains value as array use this: variableID:(index,separator)

index can be number or first, last

EXAMPLE:

In storage our data is like this: variableID -> value1, value2, value3

with this command: variableID:(last,,) will return value3

or this command: variableID:(1,,) will return value2

you can also get the item with it's index (whatever it was text or array):

[variableID][index]



Areas

area: used to define custom area like 'label' in CMD

COMMAND STRUCTURE:

area [areaName];, (command)


jump: used to jump to specific area like 'goto' in CMD

COMMAND STRUCTURE:

jump [areaName]



Runtime

delay: used to delay the script for specific time

COMMAND STRUCTURE:

delay time

time in milliseconds


break: used to break the execution and end the script

COMMAND STRUCTURE:

break message


breakwhen: used to break the execution and end the script on specific condition

COMMAND STRUCTURE:

breakwhen condition;, message

check 'is' command below for condition structure

you can use fixed condition 'offline' to break when no internet connection

check also waitic (for wait until internet active)



Batch Script

cmd: run cmd command from variable

COMMAND STRUCTURE:

cmd [variableID]

check definec / func for commands define


cmdout: run cmd command and save the output result to variable

COMMAND STRUCTURE:

cmdout [outputID];, (command)



Conditions

is: used to execute command when specific condition is true

COMMAND STRUCTURE:

is statement;, (command)

statement accept the following operators:

  • <
  • >
  • >=
  • <=
  • equ
  • ==
  • neq
  • !=
  • lss
  • leq
  • gtr
  • geq
  • ~~ (contains)
  • !~ (not contains)
  • @ (startWith)
  • # (endWith)

EXAMPLE:

is variable<18;, (break Age is not allowed)

variable (left side) can be also [variableID], because long data/text with lines will break the script

  1. You can test upto 3 values instead of two

is variable==11|18|22;, (break Age is not allowed)

  1. You can run cmd commands with 'is'

  2. You can use mulitple commands with 'is'

EXAMPLE:

is variable>0{
command..
command..
}
  1. You can get lower case content for the left side

is lower:content~~test;, (command)

  1. Internal multiple is is possible

else: used to execute command after 'is' condition is false

COMMAND STRUCTURE:

else statement;, (command)

if you don't have extra statement just use 'else'

if you want to use else without statement in one line do the following:

else (command)

multi line is possible

EXAMPLE:

is variable>0{
.....
}else statement{
.....
}

any other details same exactly as 'is' command

Clone this wiki locally