mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-08-14 15:09:02 +02:00
global-functions: introduce $CleanName
This commit is contained in:
parent
b548ffee59
commit
09988d9892
1 changed files with 19 additions and 0 deletions
|
@ -27,6 +27,7 @@
|
||||||
:global CharacterMultiply;
|
:global CharacterMultiply;
|
||||||
:global CharacterReplace;
|
:global CharacterReplace;
|
||||||
:global CleanFilePath;
|
:global CleanFilePath;
|
||||||
|
:global CleanName;
|
||||||
:global DeviceInfo;
|
:global DeviceInfo;
|
||||||
:global Dos2Unix;
|
:global Dos2Unix;
|
||||||
:global DownloadPackage;
|
:global DownloadPackage;
|
||||||
|
@ -222,6 +223,24 @@
|
||||||
:return $Path;
|
:return $Path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# clean name for DNS, file and more
|
||||||
|
:set CleanName do={
|
||||||
|
:local Input [ :tostr $1 ];
|
||||||
|
|
||||||
|
:local Return "";
|
||||||
|
|
||||||
|
:for I from=0 to=([ :len $Input ] - 1) do={
|
||||||
|
:local Char [ :pick $Input $I ];
|
||||||
|
:if ([ :typeof [ find "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-" $Char ] ] = "nil") do={
|
||||||
|
:set Char "-";
|
||||||
|
}
|
||||||
|
:if ($Char != "-" || [ :pick $Return ([ :len $Return ] - 1) ] != "-") do={
|
||||||
|
:set Return ($Return . $Char);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
:return $Return;
|
||||||
|
}
|
||||||
|
|
||||||
# get readable device info
|
# get readable device info
|
||||||
:set DeviceInfo do={
|
:set DeviceInfo do={
|
||||||
:global ExpectedConfigVersion;
|
:global ExpectedConfigVersion;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue