aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-04-27 21:17:45 +0200
committerGravatar Christian Hesse <mail@eworm.de>2021-04-28 13:58:37 +0200
commite97b3945363c8f322b7ff7f4bf65f13d887d373b (patch)
treed47eeda6a880a859ec387af1162e7d18eca62451
parent66a92c3da9a43cf4b2df33d652053f72b70898a1 (diff)
global-functions: introduce $EitherOr
-rw-r--r--global-functions11
1 files changed, 11 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index aa0ea07..48b58a6 100644
--- a/global-functions
+++ b/global-functions
@@ -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 ];