From 28be6d097d84badd99ba1c75f789a1a86fe4bfdb Mon Sep 17 00:00:00 2001 From: Michael Gisbers Date: Thu, 4 Aug 2022 00:53:47 +0200 Subject: global-functions: $GetRandomNumber: use :rndnum This is available in RouterOS 7.x... Signed-off-by: Christian Hesse --- global-functions | 10 ++-------- 1 file 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 -- cgit v1.2.3-54-g00ecf