From 910641b6fa9548e0b06f64aad82082506b03c89e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 16 Jul 2020 20:34:27 +0200 Subject: global-functions: introduce $IfThenElse --- global-functions | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/global-functions b/global-functions index fe51031..e20017b 100644 --- a/global-functions +++ b/global-functions @@ -27,6 +27,7 @@ :global GetMacVendor; :global GetRandomNumber; :global GetRandomSha256; +:global IfThenElse; :global IPCalc; :global LogPrintExit; :global MailServerIsUp; @@ -339,6 +340,14 @@ :return $FingerPrint; } +# mimic conditional/ternary operator (condition ? consequent : alternative) +:set IfThenElse do={ + :if ([ :tostr $1 ] = "true" || [ :tobool $1 ] = true) do={ + :return $2; + } + :return $3; +} + # calculate and print netmask, network, min host, max host and broadcast :set IPCalc do={ :local Input [ :tostr $1 ]; -- cgit v1.2.3-54-g00ecf