1
0
mirror of https://github.com/eworm-de/routeros-scripts.git synced 2024-05-11 05:55:19 +00:00

global-functions: $CharacterReplace: do not limit string length

I've tried something like this to update a device:

/ system script set source=[ $CharacterReplace [ get global-config-overlay source ] "GlobalConfigVersion 10" "GlobalConfigVersion 11" ] global-config-overlay;

This broke with global-config-overlay longer than 999 characters. So makes
sure there is no limit for string length.
This commit is contained in:
Christian Hesse
2020-02-03 21:29:21 +01:00
parent 0c705d5311
commit 03af7d6d9c

View File

@@ -64,7 +64,6 @@
:local String [ :tostr $1 ];
:local ReplaceFrom [ :tostr $2 ];
:local ReplaceWith [ :tostr $3 ];
:local Len [ :len $ReplaceFrom ];
:local Return "";
:if ($ReplaceFrom = "") do={
@@ -74,7 +73,7 @@
:while ([ :typeof [ :find $String $ReplaceFrom ] ] != "nil") do={
:local Pos [ :find $String $ReplaceFrom ];
:set Return ($Return . [ :pick $String 0 $Pos ] . $ReplaceWith);
:set String [ :pick $String ($Pos + $Len) 999 ];
:set String [ :pick $String ($Pos + [ :len $ReplaceFrom ]) [ :len $String ] ];
}
:return ($Return . $String);