Highlighted

Obtaining Return Value from a script object

Avatar

07-11-2008

I have a function where I am calculating a value which needs to be passed back. For example, say the function Calc gets parameters m and n via Calc(m,n) and the function calculates p = m*n. Calc(m,n,p) doesn't work. Placing a Return p at the doesn't work either and I am out of options at that point.



How do I return the value of p back. There seems to be some sort of a XFAobject issue here that I don't understand. Any help would be appreciated.

Replies

Highlighted

Avatar

Avatar

statke

Avatar

statke

statke

07-11-2008

In Designer 8.2.1, Added 2 text boxes to a form design. box1, box2.

Inserted a Script Object Scripts4 by right clicking root level form1.

Added a function in Scripts4 -

function calcu(m, n)

{

//xfa.host.messageBox("values .." + m);



var p = m*n;

return p;

}



-----



In box1.exit event; wrote following script:



v= Scripts4.calcu(box1.rawValue, 10);

box2.rawValue = v;



-----



Preview PDF, entered 14 in Box1. Clicked on Box2. It shows 140.

Working as expected.
Highlighted

Avatar

07-11-2008

statke,



Thank you so much! That was VERY helpful!



If you don't mind I have one more question that maybe you can help with.



I want to pass two Tables to a function and work on them in the function. When I reference any row from the passed table it doesn't understand it like it does the vars m and n in the example you showed me. Is there a different way to reference tables (passed as paramters) in a function?



Again, thanks a lot for your help!