Looking for some help with Text Translation. I am building a form that will be used to create a Return to Work Letter. I have a section set up with the Statement "Restrictions only apply to the checked extremities: " followed by 4 separate check boxes for Left Arm, Left Leg, Right Arm and Right Leg. I did not use a listbox because I want the checkboxes to appear on one line horizontally so that it takes up less space on the form.
I want the text translation to appear as:
Restrictions only apply to these extremities: (list based on what boxes are checked separated by comma)
I have the translation working as expected with how I have it setup but would like it to leave off the comma after the last checked option.
So it would appear as
Restrictions only apply to these extremities: Left Arm, Right Arm
rather than
Restrictions only apply to these extremities: Left Arm,RightArm,
I am sure there is a better way to set up the text translation than what I have here:
{IF STR(DOCUMENT.LA,DOCUMENT.LL,DOCUMENT.RA,DOCUMENT.RL) == "" THEN "" ELSE CFMT("
Restrictions only apply to these extremities: ", "B") + (IF DOCUMENT.LA <> "" THEN DOCUMENT.LA + "," ELSE "" ENDIF) + (IF DOCUMENT.LL <> "" THEN DOCUMENT.LL + "," ELSE "" ENDIF) + (IF DOCUMENT.RA <> "" THEN DOCUMENT.RA + "," ELSE "" ENDIF) + (IF DOCUMENT.RL <> "" THEN DOCUMENT.RL + "," ELSE "" ENDIF) + HRET ENDIF}
you really just need a space after your commas.
IF DOCUMENT.LA “” THEN DOCUMENT.LA + “,” ELSE “” ENDIF) + (IF DOCUMENT.LL “” THEN DOCUMENT.LL + “, ” ELSE “” ENDIF) + (IF DOCUMENT.RA “” THEN DOCUMENT.RA + “, ” ELSE “” ENDIF) + (IF DOCUMENT.RL “” THEN DOCUMENT.RL + “, ” ELSE “” ENDIF)
you can also use this
/*Function to add commas and and to multiple selections*/
{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 do need to add spaces after the comma's and I realized that as I was posting this but forgot to make the changes. However, that would not get rid of the comma that populates after the last checked option. I will try out the function that you posted. Thanks for your feedback!
let me know how it works out