Does anyone know the function to add the word "and" to the end of a list? I have listboxes tied to document variables and I want the translation to read:
fevers, chills, and night sweats.
fevers and chills.
as opposed to:
fevers, chills, night sweats.
fevers, chills.
Thanks!
This is what I use -
{fn ListToAnd(list){
if (list "") then
local andarray = ""
andarray = getfield(list,",","")
if size(andarray)>2 then
set(andarray,size(andarray)," and" + andarray[size(andarray)])
else if size(list)>1 then
return replacestr(str(andarray),","," and")
else return str(list) endif endif
else return "" endif
return str(andarray)
}}
great thank you so much. And do you call this from a data display or put it into the chart translation?
how does this link with the specific list box indicated?
there are functions in CCC folder CCC-fndef1.ccc called ccc_addAND(a) and ccc_AddANDtoDOC(aa) that may be of assistance to this issue. You pass in the document variable and out comes the selected items with an AND before the last item, if there are 2 or more items.
I have that in a userlib.txt file, you could put it in the code panel of any form, for text translation something like -
{CFMT(ListToAnd(DOCUMENT.LISTBOX_NAME),"","Label: ","B","
")}
For data display something like -
{ListToAnd(obsany("ROS:GENERAL"))}