aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
diff options
context:
space:
mode:
Diffstat (limited to 'global-functions')
-rw-r--r--global-functions16
1 files changed, 16 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index 7a6d77a..d4aa574 100644
--- a/global-functions
+++ b/global-functions
@@ -30,6 +30,7 @@
:global GetMacVendor;
:global GetRandom20CharHex;
:global GetRandomNumber;
+:global HexToNum;
:global IfThenElse;
:global IPCalc;
:global LogPrintExit;
@@ -425,6 +426,21 @@
:return ([ :tonum [ :pick $Num 0 18 ] ] % $Max);
}
+# convert from hex (string) to num
+:set HexToNum do={
+ :local Input [ :tostr $1 ];
+ :local Hex "0123456789abcdef";
+ :local Multi 1;
+ :local Return 0;
+
+ :for I from=([ :len $Input ] - 1) to=0 do={
+ :set Return ($Return + ([ :find $Hex [ :pick $Input $I ] ] * $Multi));
+ :set Multi ($Multi * 16);
+ }
+
+ :return $Return;
+}
+
# mimic conditional/ternary operator (condition ? consequent : alternative)
:set IfThenElse do={
:if ([ :tostr $1 ] = "true" || [ :tobool $1 ] = true) do={