Skip to content

Commit 5ede1c6

Browse files
mgisberseworm-de
authored andcommitted
global-functions: $GetRandomNumber: use :rndnum
This is available in RouterOS 7.x... Signed-off-by: Christian Hesse <mail@eworm.de>
1 parent 6a26334 commit 5ede1c6

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

global-functions

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -407,15 +407,9 @@
407407

408408
# generate random number
409409
:set GetRandomNumber do={
410-
:local Max 4294967295;
411-
:if ([ :typeof $1 ] != "nothing" ) do={
412-
:set Max ([ :tonum $1 ] + 1);
413-
}
414-
415-
:global GetRandom20CharHex;
416-
:global HexToNum;
410+
:global EitherOr;
417411

418-
:return ([ $HexToNum [ :pick [ $GetRandom20CharHex ] 0 15 ] ] % $Max);
412+
:return [ :rndnum from=0 to=[ $EitherOr [ :tonum $1 ] 4294967295 ] ];
419413
}
420414

421415
# convert from hex (string) to num

0 commit comments

Comments
 (0)