mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2024-05-11 05:55:19 +00:00
global-functions: introduce $EitherOr
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
:global DeviceInfo;
|
||||
:global DNSIsResolving;
|
||||
:global DownloadPackage;
|
||||
:global EitherOr;
|
||||
:global EscapeForRegEx;
|
||||
:global FlushEmailQueue;
|
||||
:global FlushTelegramQueue;
|
||||
@ -293,6 +294,16 @@
|
||||
:return false;
|
||||
}
|
||||
|
||||
# return either first (if "true") or second
|
||||
:set EitherOr do={
|
||||
:global IfThenElse;
|
||||
|
||||
:if ([ :typeof $1 ] = "num") do={
|
||||
:return [ $IfThenElse ($1 != 0) $1 $2 ];
|
||||
}
|
||||
:return [ $IfThenElse ([ :len [ :tostr $1 ] ] > 0) $1 $2 ];
|
||||
}
|
||||
|
||||
# escape for regular expression
|
||||
:set EscapeForRegEx do={
|
||||
:local Input [ :tostr $1 ];
|
||||
|
Reference in New Issue
Block a user