From eda75f0bbc400950d0d98ad7456096deb2a8e755 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 5 Jul 2022 12:29:29 +0200 Subject: global-functions: introduce function $PrettyPrint ... to add trailing carriage return when printing to terminal: [admin@MikroTik] > $PrettyPrint [ $DeviceInfo ] Hostname: MikroTik Board name: hAP ac^2 Architecture: arm Model: RouterBOARD D52G-5HacD2HnD-TC Serial number: 8A2A09A221A1 RouterOS: Channel: testing Installed: 7.4rc1 RouterOS-Scripts: Current: 81 --- global-functions | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/global-functions b/global-functions index 3a2497e..daa6526 100644 --- a/global-functions +++ b/global-functions @@ -40,6 +40,7 @@ :global MkDir; :global NotificationFunctions; :global ParseKeyValueStore; +:global PrettyPrint; :global QuotedPrintable; :global RandomDelay; :global Read; @@ -648,6 +649,15 @@ :return $Result; } +# print lines with trailing carriage return +:set PrettyPrint do={ + :local Input [ :tostr $1 ]; + + :global CharacterReplace; + + :put [ $CharacterReplace $Input ("\n") ("\n\r") ]; +} + # convert string to quoted-printable :global QuotedPrintable do={ :local Input [ :tostr $1 ]; -- cgit v1.2.3-70-g09d2