Hello,
I have a data display field named DOCUMENT.RETURN1, with a CFMT in the chart note translation.
I would like to reuse the following function (simplified for this post) throughout a form. At this point it is completely reusable except that I cannot figure out how to leverage “return1” (which holds the name of the data display field) to return the text translation to the DOCUMENT.RETURN1 field. I hope this makes sense!
Run Process behind a button:
{fn_Write(
"TITLE TO USE IN TEXT TRANSLATION"//title1
, "DOCUMENT.VARIABLE1"//(pass to doc1)
,"DOCUMENT.VARIABLE2"//(pass to doc2)
,"DOCUMENT.VARIABLE3"//(pass to doc3)
,"DOCUMENT.RETURN1" //return1: Document variable to receive the returned value from the function)
}
Click button above to execute this Function:
{fn fn_write(title1,doc1,doc2,doc3,return1){
dVar1 = "" dVar1 = if (eval(doc1)== "") then dVar1 = "" else
dVar1 = CFMT(eval(doc1) , "" , "" , "" , "" + HRET) endif
dVar2 = "" dVar2 = CFMT(eval(doc2) , "" , "" , "" , "" + HRET)
dVar3 = "" dVar3 = CFMT(eval(doc3) , "" , "" , "" , "" + HRET)
if str(dVar1, dVar2, dVar3)== "" then dVar4 = "" else
dVar4 = str(FMT(hret + title1 + hret, "B,1") + dVar1 + dVar2 + dVar3) endif
DOCUMENT.RETURN1 = str(dVar4) //This returns the proper translation to the proper place, but I need to recognize the variable name (return1) and pass the translation to the document variable (DOCUMENT.RETURN1) so the function can be reused.
SIMILAR TO: Eval(return1 + “=” + str(dVar4))
}}
I've tried everything I can think of go nail down that last line of code. Can anyone suggest the proper syntax to get this to work?
Thank you so much!
Cyd
You want something like one of these -
{eval("document.return1= \"" + str(dvar4) + "\"")}
{eval("document.return" + return1 + " = \"" + str(dvar4) + "\"")}
{eval("document." + return1 + " = \"" + str(dvar4) + "\"")}
Thank you for your reply, this led me in the right direction!
In case anyone returns to the board with a similar issue, this is the code that finally gave me what I needed:
eval(return1 + " = " + "'" + dVar4 + "'")
note: "'" = Double-quote Single-quote Double-quote (no spaces).
Thank you again. I appreciate the help!
Cyd