bob cart:
In practice, I want to name f-name and fname stuff like “Projected” or “Year_to_Date” so the user can understand the meaning. In Filemaker, I can name fields Projected and Year_to_Date then use getfield(column_choice) to show the correct value. Very easy and powerful. So how can I do this in Servoy? I hope you just tell me that I’m missing the object model and this type of use is “baked in”. It just seems to me that the element references are so explicit and hierarchical that you’d have to another level of abstraction to convert t he human readable variable to the field it needs to reference to if
if column_choice = “Projected” return forms.formA.elements.fname.selectedText() etc.
I know this may seem like extra work…
But you’ll find a lot of power in working with arrays in Javascript.
It sounds like you’ll need to create a field map. This is where you’ll map the human readable name such as “Projected” to the element reference (ultimately, the field). Since most SQL db systems don’t use human readable names, in favor of more verbose nomenclature, this may be something you need to code. Although, I don’t see why it wouldn’t be possible to write a method that would do what you want - you’ll just have to stick to an explicit method of naming your elements in relation to the names of fields.
By working with Javascript arrays you’ll be able to modify your field maps quite easily. If you haven’t created the db yet then you also have the opportunity of making the field map more programatically easy. Case in point…
You could name your fields like such.
sales_amnt_amount-hr
Where the first word is the table name, the second word is your developer field name and the last word is your human readable word.
You would then use Servoy’s Database Manager and javascript arrays to grab all the column names of all tables into an array and populate a value list with all fields ending with -hr. Of course you’d have to strip that -hr.
The point here is that after you’ve writen the routine, in anticipation of controlling the future nomenclature, the next time you add a field named with an -hr at the end your routine will pick it up and make it available into your field map.
That’s one way of doing it. Working with nomenclature that accomodates methods that expect certain naming conventions.
Another method is to make a table that will contain your field map. This only requires you to have three fields. The human readable name, the element name and the object reference. Using this method you just add a new row to the table that maps to the proper element or field.
I think you’ll find that doing things in Servoy may require a bit more development on the front end but the end result will be much more flexible in the long run.
I would go here and just play with some JavaScript arrays. Just to see what you can do. If you already know about arrays then I hope I didn’t offend. ![Wink :wink:]()
http://devedge.netscape.com/library/manuals/2000/javascript/1.5/guide/obj.html#1008453