mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-03 06:34:27 +02:00
global-functions: $GetRandomNumber: use :rndnum
This is available in RouterOS 7.x... Signed-off-by: Christian Hesse <mail@eworm.de>
This commit is contained in:
parent
0562198c55
commit
28be6d097d
1 changed files with 2 additions and 8 deletions
|
@ -407,15 +407,9 @@
|
||||||
|
|
||||||
# generate random number
|
# generate random number
|
||||||
:set GetRandomNumber do={
|
:set GetRandomNumber do={
|
||||||
:local Max 4294967295;
|
:global EitherOr;
|
||||||
:if ([ :typeof $1 ] != "nothing" ) do={
|
|
||||||
:set Max ([ :tonum $1 ] + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
:global GetRandom20CharHex;
|
:return [ :rndnum from=0 to=[ $EitherOr [ :tonum $1 ] 4294967295 ] ];
|
||||||
:global HexToNum;
|
|
||||||
|
|
||||||
:return ([ $HexToNum [ :pick [ $GetRandom20CharHex ] 0 15 ] ] % $Max);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# convert from hex (string) to num
|
# convert from hex (string) to num
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue