blob: 15da04a36f6ec5e4efebbf874b5d4c0c978eba51 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!rsc by RouterOS
# RouterOS script: global-functions.d/inspectvar
# Copyright (c) 2020-2021 Christian Hesse <mail@eworm.de>
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
:global InspectVar;
# inspect variable
:set InspectVar do={
:local Input $1;
:local Level (0 + [ :tonum $2 ]);
:global InspectVar;
:local PutIndent do={
:local Prefix [ :tostr $1 ];
:local Value [ :tostr $2 ];
:local Level [ :tonum $3 ];
:local Indent "";
:for I from=1 to=$Level step=1 do={
:set Indent ($Indent . " ");
}
:put ($Indent . "-" . $Prefix . "-> " . $Value);
}
:local TypeOf [ :typeof $Input ];
$PutIndent "type" $TypeOf $Level;
:if ($TypeOf = "array") do={
:foreach Key,Value in=$Input do={
$PutIndent "key" $Key ($Level + 1);
$InspectVar $Value ($Level + 2);
}
} else={
:if ($TypeOf != "nothing") do={
$PutIndent "value" $Input $Level;
}
}
}
|