Is there a way to make it so that when you have multiple checkboxes that it will put a comma between all except the last one chosen and place the word and there
combines any number of strings with the given (first parameter) delimiter (i.e. CombineLastAnd(", ", string1, string2, …)) and inserting ' and ' before last string
{fn CombineLastAnd()
{
local nargs = GETNARGS()
local delim
local result = ""
local index
local arg
if nargs>0 then
delim = GETARG(1)
for index = 2, index <= nargs, index = index + 1 do
arg = GETARG(index)
if arg<>"" then
if result<>"" then
if index = nargs then
result = result + " and " + STR(arg)
else
result = result + STR(delim) + STR(arg)
endif
else
result = STR(arg)
endif
endif
endfor
endif
return STR(result)
}
}
I am having a complete blank. Can you show me in this form. I'm sorry.
CombineLastAnd(", ", check1, check2, check3, check4) will return check1 + ', ' + check2 + ', ' + check3 + ' and ' + check4
add 'and' before last item from a listbox.
{fn add_and(list)
{
if list == "" then
return ""
else
if MATCH(list, ",") == 0 then
return list
else
local x = GETFIELD(list, ",", "")
return STR(SUB(x, 1, SIZE(x) - 1), ",") + " and" + STR(x[SIZE(x)]) + "."
endif
endif
}
}