Hello @Poel van der, RE (Ron) and thank you for your question.
Yes there is an "IF" command you can use. It is spelled with two 'i'. iif(condition, do_if_true, do_if_false)
.
I notice that the examples you gave are words separated by comma (,). Since there is no comma when you have only one name, and one or more commas when you have two or more names, we can just do logic on whether or not a comma exists in $Logicalkey.
There are multiple ways we can check for the comma.
like, regexMatch, locate
iif(like($Logicalkey,'%,%'),md5(byNames($Logicalkey)),md5(byName($Logicalkey)))
if you are confident your $Logicalkey will never be malformed ( "one," ",two" "," "inter,rupt,two") , then like is sufficient to use (see above).
iif(2 < locate(',', $Logicalkey), md5(byNames($Logicalkey)),md5(byName($Logicalkey)))
if you want to be a little more careful, and preclude some malformed inputs, then use like (see above). This avoids starting with comma.
For maximum protection, use regexMatch.
regexMatch($Logicalkey, '((\w+),(\w+))+' )
If I wrote this correctly, it means at least one repetition of ( 1 or more word characters, followed by a comma, followed by one or more word characters).