I am trying to concatenate 6 yes/no questions and have them listed with a comma in between. I don't want to have the last variable have a comma at the end and can't seem to figure this out
I was linking them in an edit box and hard coded a comma in between each, but if one of the questions isn't answered, it puts the extra comma in there... What I would like to see is "answer, answer." instead of "answer, , answer."
Can someone help me out with this?
Example:
{ if (DOCUMENT.DONE4=="") then CFMT(OBSNOW("DISSECTINSEG", DOCUMENT.DONE1 + ", " + DOCUMENT.DONE2 + ", " + DOCUMENT.DONE3 + ", "+ DOCUMENT.DONE5 + " "), "", " Tests completed during preceeding visit: ", "B", " ") else CFMT(OBSNOW("DISSECTINSEG", "None"), "", " No testing performed during preceeding visit.", "B"," ") endif }
combines any number of strings with the given (first parameter) delimiter (i.e. Combine(", ", string1, string2, ...))
{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)
}
}