mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: $HexToNum: use :tonum
This commit is contained in:
parent
be4221264c
commit
29623a46ea
1 changed files with 5 additions and 7 deletions
|
@ -488,16 +488,14 @@
|
||||||
# convert from hex (string) to num
|
# convert from hex (string) to num
|
||||||
:set HexToNum do={
|
:set HexToNum do={
|
||||||
:local Input [ :tostr $1 ];
|
:local Input [ :tostr $1 ];
|
||||||
:local Hex "0123456789abcdef0123456789ABCDEF";
|
|
||||||
:local Multi 1;
|
|
||||||
:local Return 0;
|
|
||||||
|
|
||||||
:for I from=([ :len $Input ] - 1) to=0 do={
|
:global HexToNum;
|
||||||
:set Return ($Return + (([ :find $Hex [ :pick $Input $I ] ] % 16) * $Multi));
|
|
||||||
:set Multi ($Multi * 16);
|
:if ([ :pick $Input 0 ] = "*") do={
|
||||||
|
:return [ $HexToNum [ :pick $Input 1 [ :len $Input ] ] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
:return $Return;
|
:return [ :tonum ("0x" . $Input) ];
|
||||||
}
|
}
|
||||||
|
|
||||||
# return human readable number
|
# return human readable number
|
||||||
|
|
Loading…
Reference in a new issue