Hi,
What is the difference in declaring of a variable in Mongoose form script
Option 1: public string myStr = "ABC";
Option 2: ThisForm.Variables("myStr").Value = "ABC";
Regards,
Kirill
Option 1 is a code variable specific to the form script code and cannot be referenced from with the form itself.
Option 2 sets the value of a form variable from within form script code. This variable can be referenced from within the form, in a component or event handler, etc.
Both do different things.
The "public string..." statement declares a string variable/object inside your FormScript code.
The "ThisForm.Variables..." line says "On the Form itself, set the Form variable 'myStr' to "ABC".
Thanks!
I noticed that when I do
public string myStr = "ABC";
I can't see the variable in event handler.
Stephen's description on this was accurate. When you say: "public string myStr = "ABC";", you're creating a variable whose scope is just that script, and it's not seen by the rest of Mongoose. If you wish to use it in Mongoose, then you need to take the other approach, and set a Mongoose variable (which can be used/accessed across all parts of your Mongoose session).