Hi Juliano,
Happy to have helped you!
BTW...a real ternary operator would have a larger perimeter! The user defined function I've provided accept only strings while a real ternary operator would accept any data type for value1 and value2 (numbers, dates, ...).
IMHO the request for a real ternary operator remains a nice to have wish.
Gianni
------------------------------
Gianni Sandigliano
IT
------------------------------
Original Message:
Sent: 08-16-2022 15:31
From: Juliano Garcia
Subject: Ternary Operator?
Thank you Gianni.
------------------------------
Juliano Garcia
Suport Analyst
Coamo -Coop. Agropecuaria Mouraoense
Campo Mourão BR
Original Message:
Sent: 08-13-2022 04:57
From: Gianni Sandigliano
Subject: Ternary Operator?
Hi Juliano,
Ah...what I usually use as IIF(condition, value1, value2).
You can build a function by yourself, putting it into SYSTEM_LIBRARY:
entry iif
returns string
params
string pCond : IN
string pOne : IN
string pTwo : IN
endparams
if (pCond = "") return("")
if ($condition(pCond) | $uppercase($rtrim($ltrim(pCond, " "), " ")) = "TRUE")
return(pOne)
else
return(pTwo)
endif
end
Take care to read about $condition into Uniface manuals.
I hope it could help you.
Regards,
Gianni
------------------------------
Gianni Sandigliano
IT
Original Message:
Sent: 08-12-2022 13:22
From: Juliano Garcia
Subject: Ternary Operator?
Hi Gianni,
This tree state option I already know, it would be something like:
v_result = (a = true ? 'a' : 'b' )
;v_result "a"
------------------------------
Juliano Garcia
Suport Analyst
Coamo -Coop. Agropecuaria Mouraoense
Campo Mourão BR
Original Message:
Sent: 08-12-2022 11:49
From: Gianni Sandigliano
Subject: Ternary Operator?
Hi Juliano,
If you mean a checkbox with True/False/Null: it's a widget option...
Regards,
Gianni
------------------------------
Gianni Sandigliano
IT
Original Message:
Sent: 08-12-2022 06:41
From: Juliano Garcia
Subject: Ternary Operator?
Good Morning,
What is the possibility of uniface having the ternary operator?
------------------------------
Juliano Garcia
Suport Analyst
Coamo -Coop. Agropecuaria Mouraoense
Campo Mourão BR
------------------------------