mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-14 12:04:29 +02:00
global-functions: $GetRandomNumber: use $HexToNum
This commit is contained in:
parent
cfc400b3d5
commit
679917390b
1 changed files with 2 additions and 11 deletions
|
@ -416,18 +416,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
:global GetRandom20CharHex;
|
:global GetRandom20CharHex;
|
||||||
|
:global HexToNum;
|
||||||
|
|
||||||
:local Num;
|
:return ([ $HexToNum [ :pick [ $GetRandom20CharHex ] 0 15 ] ] % $Max);
|
||||||
:local 40CharHex ([ $GetRandom20CharHex ] . [ $GetRandom20CharHex ]);
|
|
||||||
|
|
||||||
:for I from=0 to=39 do={
|
|
||||||
:local Char [ :pick $40CharHex $I ];
|
|
||||||
:if ($Char~"[0-9]") do={
|
|
||||||
:set Num ($Num . $Char);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
:return ([ :tonum [ :pick $Num 0 18 ] ] % $Max);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# convert from hex (string) to num
|
# convert from hex (string) to num
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue