How to use "allvariables" under form variables?

Questions, tips and tricks and techniques for scripting in Servoy

How to use "allvariables" under form variables?

Postby Westy » Fri Apr 11, 2014 9:42 pm

In Solution Explorer, under form variables "allvariables" is listed. When I right-click "allvariables" and select "Move sample" the following appears.

var varNames = allvariables;
application.output("This form has " + varNames.length + " variables defined.")
for (var i = 0; i < varNames.length; i++)
application.output(varNames[i]);

When I attempt to run the above method an error returns on the first line. What should I do to make this sample work?

I am hoping the above might help me with an issue that I am trying to resolve. I first use event.getElementName() to obtain the name of a button. Then I use a substring of that button's name to obtain a form variable name. No problem so far. Then I want to assign a value to the form variable that has that name. How do I convert the literal text of the variable name into the actual variable, so that I can assign a value to it?

Dean
Westy
 
Posts: 845
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Re: How to use "allvariables" under form variables?

Postby Harjo » Sat Apr 12, 2014 12:04 am

['yourvariable'] = 1
Harjo Kompagnie
Direct ICT / Servoy Hosting / ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
User avatar
Harjo
 
Posts: 4307
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: How to use "allvariables" under form variables?

Postby Westy » Sat Apr 12, 2014 5:26 am

Perfect. Thank you very much.

Dean
Westy
 
Posts: 845
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA


Return to Methods

Who is online

Users browsing this forum: No registered users and 2 guests