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

global-functions: add $ParseKeyValueStore

This commit is contained in:
Christian Hesse
2019-07-17 16:27:21 +02:00
parent 16f04ee7ee
commit f79ba55637

View File

@ -226,3 +226,19 @@
}
:return true;
}
# parse key value store
:global ParseKeyValueStore do={
:global CharacterReplace;
:local Source $1;
:if ([ :typeof $Source ] != "array") do={
:set Source [ :tostr $1 ];
}
:local Result [ :toarray "" ];
:foreach KeyValue in=[ :toarray $Source ] do={
:set KeyValue [ :toarray [ $CharacterReplace $KeyValue "=" "," ] ];
:set ($Result->($KeyValue->0)) ($KeyValue->1);
}
:return $Result;
}