Skip to content

Commit

Permalink
global-functions: $GetRandomNumber: use :rndnum
Browse files Browse the repository at this point in the history
This is available in RouterOS 7.x...

Signed-off-by: Christian Hesse <[email protected]>
  • Loading branch information
mgisbers authored and eworm-de committed Aug 5, 2022
1 parent 6a26334 commit 5ede1c6
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions global-functions
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5ede1c6

Please sign in to comment.