So I have a form with multiple list boxes each has 5 to 10 choices, I have it to where when check they document left to right with commas in the appropriate place except when the very first list box is empty then I get a comma documenting first the whatever is in the following list boxes.
Heres the code:
{OBSNOW("Plan", ListBoxResult8(DOCUMENT.LISTBOX,DOCUMENT.LISTBOX2,DOCUMENT.LISTBOX3,DOCUMENT.LISTBOX4))}
{fn ListBoxResult8(stra,strb,strc,strd){
local whlstr=""
if (size(stra) > 0) then
whlstr = stra
endif
if (size(strb) > 0) then
whlstr = whlstr + ", " + strb
endif
if (size(strc) > 0) then
whlstr = whlstr + ", " + strc
endif
if (size(strd) > 0) then
whlstr = whlstr + ", " + strd
endif
return whlstr
}
}{fn ListBoxTranslation8(label,stra,strb,strc,strd){
local whlstr = ListBoxResult8(stra,strb,strc,strd)
return cfmt(whlstr, "\,1", label + ":
", ",1", "
", ",1")
}}
Any help would be great. Thanks in advance!
{fn Combine()
{
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
result = result + STR(delim) + STR(arg)
else
result = STR(arg)
endif
endif
endfor
endif
return STR(result)
}
}
{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
}
}
{add_and(Combine(",", field1, field2, etc.))
}
Thank you! Ill be sure to save this.
One last thing, which function goes in the item on the form itself
{add_and(Combine(",", field1, field2, etc.))}
