In addition to the available variable types introduced in chapter 2.1, the system provides built-in functions for you to define compound variables to convert predefined variables in terms of variable types, units, values, etc.
Note: A compound variable must be a single-value variable of the string, integer, or double type.
The following table introduces the built-in functions that will assist you in defining compound variables.
Function Name |
Description |
Data Type of Input Parameter |
Sample of Input Parameter |
Data Type of Return |
Sample of Return |
IPStringToNumber |
Convert an IP address from string format to an integer. Masked IP address is allowed, e.g., “192.168.91.1/28”. Note: Returning “-1” represents error. |
String |
IPStringToNumber(“192.168.91.1”) |
Int (long) |
3232258817 |
NumberToIPString |
Convert an IP address from integer format to string format. Note: Returning NULL (“”) represents error. |
Int (long) |
NumberToIPString(3232258817) |
String |
“192.168.91.1” |
PercentageToNumber |
Remove the percentage sign (%). Note: Returning “-1” represents error. |
String |
PercentageToNumber(“50%”) |
Int |
50 |
ByteConverter |
Convert storage units (such as KB, MB, GB, etc.) to byte. Note: The input parameter is case-insensitive, and abbreviations are allowed, e.g., GB, G, g. Note: Returning “-1” represents error. |
String |
ByteConverter(“35MB”) |
Int |
36,700,160 Bytes |
NumberToString |
Convert a number to string format. Note: Returning NULL (“”) represents error. |
Int |
NumberToString(5) |
String |
"5" |
StringToNumber |
Convert a string-type number to int or double format. |
String |
NumberToString(“19”) |
Int |
19 |
IPtoHostname |
Obtain a device hostname by using a given IP address. Masked IP address is allowed, e.g., “192.168.91.1/24”. Note: If an IP address is being used by multiple devices, the hostname of a random device among those matches will be returned. |
String |
IPtoHostname(“192.168.91.1”) |
String |
“R1” |
TrimRight |
Trim one or more characters on the right side of a given string. If the designated character is left blank, it will be identified as a space character. Format: TrimRight($var, ”char”) |
String (original string), String (char) |
TrimRight(“4.03,” ”,”) |
String |
“4.03” |
TrimLeft |
Trim one or more characters on the left side of a given string. If the designated character is left blank, it will be identified as a space character. Format: TrimLeft($var, “char”) |
String (original string), String (char) |
TrimLeft(”-4.03”, ”-“) |
String |
“4.03” |
Replace |
Replace one character with another in a given string. Format: Replace($var, “char_old”, “char_new”) |
String (original string), String (old char), String (new char) |
Replace(”2020-8-23”, “-”, “/“) |
String |
“2020/8/23” |
FormatMAC |
Format MAC addresses using NetworkBrain-specific standard (period-separated hexadecimal notation). |
String |
FormatMAC(“D8-67-D9-86-59-40”) |
String |
“d867.d986.5940” |