aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
diff options
context:
space:
mode:
authorGravatar Michael Gisbers <michael@gisbers.de>2022-08-04 00:53:47 +0200
committerGravatar Christian Hesse <mail@eworm.de>2022-08-05 22:58:55 +0200
commit28be6d097d84badd99ba1c75f789a1a86fe4bfdb (patch)
tree257f6d9ad29caef53df76607f14532ac637affea /global-functions
parent0562198c55cea78e984b07e7f753e198fb3bb7a5 (diff)
global-functions: $GetRandomNumber: use :rndnum
This is available in RouterOS 7.x... Signed-off-by: Christian Hesse <mail@eworm.de>
Diffstat (limited to 'global-functions')
-rw-r--r--global-functions10
1 files changed, 2 insertions, 8 deletions
diff --git a/global-functions b/global-functions
index 01c9160..cd8342b 100644
--- a/global-functions
+++ b/global-functions
@@ -407,15 +407,9 @@
# generate random number
:set GetRandomNumber do={
- :local Max 4294967295;
- :if ([ :typeof $1 ] != "nothing" ) do={
- :set Max ([ :tonum $1 ] + 1);
- }
-
- :global GetRandom20CharHex;
- :global HexToNum;
+ :global EitherOr;
- :return ([ $HexToNum [ :pick [ $GetRandom20CharHex ] 0 15 ] ] % $Max);
+ :return [ :rndnum from=0 to=[ $EitherOr [ :tonum $1 ] 4294967295 ] ];
}
# convert from hex (string) to num