I hope I'm asking this question correctly...
Is there/ will there be a function that might allow me to access a field value by reference instead of having to use its name directly?
For example, I have 25 skills, which I represent each skill with its name, rank and modifiers. Fields: Skill1, Rank1, Mod1; Skill2, Rank2, Mod2, ..., Skill25, Rank25, Mod25.
I've been accessing each field as it is named (typed out in the code), which can get very extensive. It would be nice if there was a way to access those field values by reference using a string such as Field('Skill' + varx).Value, Field('Rank' + varx).Value, Field('Mod' + varx).Value.
Comments
you can do something like this.
The trick is using the eval() function. Its not really considered a good thing to do, but it is the only way I have found to do what you want.
Your snippet helped me writing a script function that can evaluate a dynamic formula.
Example.
Say you have DataStore with named Skills Add field Dexterity
Add field Quickness
Add field Strength
Add field Skill1 with List property := Skills This will make it a drop down box with all items in the datastore
Add field SkillFormula1 with Field Source := Lookup( 'Skills', Skill1.Text, 'Attribute') This will display the formula for selected item
Add field FormulaResult1 with Field Source := CalculateSkillPotential(SkillFormula1.Text) This will calculate the value of the formula using fields in the sheet
Some extra field for user information, txtOut and txtError
Comments on the code above.
Using dots(.) in string functions is tricky since the dot is a special character in javascript. That is why the escape character "\" is used in conjunction with the dot(\.)
Support function