mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-10 18:14:27 +02: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 DownloadPackage;
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
:global EscapeForRegEx;
|
:global EscapeForRegEx;
|
||||||
|
:global FormatLine;
|
||||||
:global GetMacVendor;
|
:global GetMacVendor;
|
||||||
:global GetRandom20CharAlNum;
|
:global GetRandom20CharAlNum;
|
||||||
:global GetRandom20CharHex;
|
:global GetRandom20CharHex;
|
||||||
|
@ -329,6 +330,32 @@
|
||||||
:return $Return;
|
: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
|
# get MAC vendor
|
||||||
:set GetMacVendor do={
|
:set GetMacVendor do={
|
||||||
:local Mac [ :tostr $1 ];
|
:local Mac [ :tostr $1 ];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue