mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: introduce $FormatLine
This commit is contained in:
parent
fb9feea595
commit
cb338c76a8
1 changed files with 27 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
|||
:global DownloadPackage;
|
||||
:global EitherOr;
|
||||
:global EscapeForRegEx;
|
||||
:global FormatLine;
|
||||
:global GetMacVendor;
|
||||
:global GetRandom20CharAlNum;
|
||||
:global GetRandom20CharHex;
|
||||
|
@ -329,6 +330,32 @@
|
|||
:return $Return;
|
||||
}
|
||||
|
||||
# format a line for output
|
||||
:set FormatLine do={
|
||||
:local Key [ :tostr $1 ];
|
||||
:local Values [ :toarray $2 ];
|
||||
:local Indent [ :tonum $3 ];
|
||||
:local Spaces " ";
|
||||
:local Return "";
|
||||
|
||||
:global EitherOr;
|
||||
:global FormatLine;
|
||||
|
||||
:set Indent [ $EitherOr $Indent 16 ];
|
||||
|
||||
:if ([ :len $Key ] > 0) do={ :set Return ($Key . ":"); }
|
||||
:if ([ :len $Key ] > ($Indent - 2)) do={
|
||||
:set Return ($Return . "\n" . [ :pick $Spaces 0 $Indent ] . ($Values->0));
|
||||
} else={
|
||||
:set Return ($Return . [ :pick $Spaces 0 ($Indent - [ :len $Return ]) ] . ($Values->0));
|
||||
}
|
||||
:foreach Value in=[ :pick $Values 1 [ :len $Values ] ] do={
|
||||
:set Return ($Return . "\n" . [ $FormatLine "" ({$Value}) $Indent ]);
|
||||
}
|
||||
|
||||
:return $Return;
|
||||
}
|
||||
|
||||
# get MAC vendor
|
||||
:set GetMacVendor do={
|
||||
:local Mac [ :tostr $1 ];
|
||||
|
|
Loading…
Reference in a new issue