Hello! Hoping for help with text translation of the function below. I want the strings separated by a hard return and it works as long as I choose document variables that are next to each other.
I need the text translation to be separated by 1 hard return, no matter how far apart the document variable are. (Example: If I select INSTRU1 and INSTRU20, I only want hard return between them.
Does that even make sense?
//Assessment Tab Start//
{ ConcatenateText(DOCUMENT.INSTRU1,DOCUMENT.INSTRU2,DOCUMENT.INSTRU3,DOCUMENT.INSTRU4,DOCUMENT.INSTRU5,DOCUMENT.INSTRU6,DOCUMENT.INSTRU7,DOCUMENT.INSTRU8,DOCUMENT.INSTRU9,DOCUMENT.INSTRU10,DOCUMENT.INSTRU11,DOCUMENT.INSTRU12,DOCUMENT.INSTRU13,DOCUMENT.INSTRU14,DOCUMENT.INSTRU15,DOCUMENT.INSTRU16,DOCUMENT.INSTRU17,DOCUMENT.INSTRU18,DOCUMENT.INSTRU19,DOCUMENT.INSTRU20)}
{ fn ConcatenateText(strvar1,strvar2,strvar3,strvar4,strvar5,strvar6,strvar7,strvar8,strvar9,strvar10,strvar11,strvar12,strvar13,strvar14,strvar15,strvar16,strvar17,strvar18,strvar19,strvar20)
{
local obsstr=""
//following line needs to be modified as you wish to separate strings
obsstr=
strvar1+HRET+HRET+
strvar2+HRET+HRET+
strvar3+HRET+HRET+
strvar4+HRET+HRET+
strvar5+HRET+HRET+
strvar6+HRET+HRET+
strvar7+HRET+HRET+
strvar8+HRET+HRET+
strvar9+HRET+HRET+
strvar10+HRET+HRET+
strvar11+HRET+HRET+
strvar12+HRET+HRET+
strvar13+HRET+HRET+
strvar14+HRET+HRET+
strvar15+HRET+HRET+
strvar16+HRET+HRET+
strvar17+HRET+HRET+
strvar18+HRET+HRET+
strvar19+HRET+HRET+
strvar20
obsnow("INSTRUCTIONS",obsstr)
}
Use concatenated inline if() statements:
obsstr=(if strvar1=="","",strvar1+HRET)+(if strvar2=="","",strvar2+HRET)+.........
This is what I changed it to:
//Assessment Tab Start//
{ ConcatenateText(DOCUMENT.INSTRU1,DOCUMENT.INSTRU2,DOCUMENT.INSTRU3,DOCUMENT.INSTRU4,DOCUMENT.INSTRU5,DOCUMENT.INSTRU6,DOCUMENT.INSTRU7,DOCUMENT.INSTRU8,DOCUMENT.INSTRU9,DOCUMENT.INSTRU10,DOCUMENT.INSTRU11,DOCUMENT.INSTRU12,DOCUMENT.INSTRU13,DOCUMENT.INSTRU14,DOCUMENT.INSTRU15,DOCUMENT.INSTRU16,DOCUMENT.INSTRU17,DOCUMENT.INSTRU18,DOCUMENT.INSTRU19,DOCUMENT.INSTRU20)}
{ fn ConcatenateText(strvar1,strvar2,strvar3,strvar4,strvar5,strvar6,strvar7,strvar8,strvar9,strvar10,strvar11,strvar12,strvar13,strvar14,strvar15,strvar16,strvar17,strvar18,strvar19,strvar20)
{
local obsstr=""
//following line needs to be modified as you wish to separate strings
obsstr=
(if strvar1=="",""strvar1+HRET)+
(if strvar2=="",""strvar2+HRET)+
(if strvar3=="",""strvar3+HRET)+
(if strvar4=="",""strvar4+HRET)+
(if strvar5=="",""strvar5+HRET)+
(if strvar6=="",""strvar6+HRET)+
(if strvar7=="",""strvar7+HRET)+
(if strvar8=="",""strvar8+HRET)+
(if strvar9=="",""strvar9+HRET)+
(if strvar10=="",""strvar10+HRET)+
(if strvar11=="",""strvar11+HRET)+
(if strvar12=="",""strvar12+HRET)+
(if strvar13=="",""strvar13+HRET)+
(if strvar14=="",""strvar14+HRET)+
(if strvar15=="",""strvar15+HRET)+
(if strvar16=="",""strvar16+HRET)+
(if strvar17=="",""strvar17+HRET)+
(if strvar18=="",""strvar18+HRET)+
(if strvar19=="",""strvar19+HRET)+
strvar20
obsnow("INSTRUCTIONS",obsstr)
}
And this is the error I'm getting when the form is opened in Centricity:
{
/*FUNCTION DEFINITIONS*/
fn ConcatenateText(strvar1,strvar2,strvar3,strvar4,strvar5,strvar6,strvar7,strvar8,strvar9,strvar10,strvar11,strvar12,strvar13,strvar14,strvar15,strvar16,strvar17,strvar18,strvar19,strvar20)
{
local obsstr=""
//following line needs to be modified as you wish to separate strings
obsstr=
(if strvar1=="",""strvar1 <-COMPILER ERROR NEARBY: Expect RIGHT PAREN. Instead had IDENTIFIER after STRING
The syntax used is MEL shorthand, and it is rather picky.
(if strvar1=="",""strvar1+HRET)+
Reads as:
(if strvar1=="" then"" else strvar1+HRET endif)+
Knowing this, you need to add a second comma after the second set of quotes:
(if strvar1=="","",strvar1+HRET)+
This should clean it up for you.
A cleaner approach to this functionality would be:
{! fn fnBuildInstr()
{
local retStr = ""
local strBuf = ""
local i
local nArgs
nArgs = getnargs()
for i = 1, i <= size(nArgs), i = i + 1 do
strBuf = getarg(i)
if strBuf <> "" then
if retStr <> "" then
retStr = retStr + HRET + strBuf
else
retStr = strBuf
endif
else ""
endif
endfor
obsnow("INSTRUCTIONS",retStr)
return ""
}
}
You would still create the 'standard' function call, however:
fnBuildInstr(DOCUMENT.INSTRU1,DOCUMENT.INSTRU2,DOCUMENT.INSTRU3, etc.)
This makes the function easily used in other contexts with minimal modification of the obsterm assignment method.