diff options
author | Christian Hesse <mail@eworm.de> | 2024-01-16 22:20:19 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2024-01-16 22:24:50 +0100 |
commit | 29623a46ea1658cc8c9fcb4832f0810612addde5 (patch) | |
tree | fb1e29ffb89ed2b49facb4c370e3de1673839611 /global-functions.rsc | |
parent | be4221264ca6dd2f69f3d8cea8a2aaa65cf5580b (diff) |
global-functions: $HexToNum: use :tonum
Diffstat (limited to 'global-functions.rsc')
-rw-r--r-- | global-functions.rsc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/global-functions.rsc b/global-functions.rsc index 8dd1f07..af82fa8 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -488,16 +488,14 @@ # convert from hex (string) to num :set HexToNum do={ :local Input [ :tostr $1 ]; - :local Hex "0123456789abcdef0123456789ABCDEF"; - :local Multi 1; - :local Return 0; - :for I from=([ :len $Input ] - 1) to=0 do={ - :set Return ($Return + (([ :find $Hex [ :pick $Input $I ] ] % 16) * $Multi)); - :set Multi ($Multi * 16); + :global HexToNum; + + :if ([ :pick $Input 0 ] = "*") do={ + :return [ $HexToNum [ :pick $Input 1 [ :len $Input ] ] ]; } - :return $Return; + :return [ :tonum ("0x" . $Input) ]; } # return human readable number |