Get the names of all object type within a group
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Get the names of all object type within a group
I am trying to come up with a method to automatically get and send all the contents of different fields and store them in a database. It would be for something like storing persistent values based on who is using the program. I was thinking if I can put all the fields in a group, and get all the names of the fields within the group into a list via a livecode function, then I can automatically go through the list and put their contents into a database with columns for the username, card name, field name, and field contents. How can I do this?
Re: Get the names of all object type within a group
Hi buchacho,
Fun stuff.
Simon 
Edit: oops
Fun stuff.
Code: Select all
repeat with x = 1 to the number of fields of this cd --number of fields of group "myGroup" of this cd
put the text of fld x & cr after myVar
end repeat

Edit: oops
...and get all the names of the fields within the group...
Code: Select all
put the name of fld x & cr after myVar
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Get the names of all object type within a group
You could use as well custom properties, that would contain the name of the column and be used as a "flag" (to know for instance if the field must be "emptied" before to display another record)
My point : on your card, you might have fields (labels for instance, or fields in datagrid) that won't be meaningful for your database. Using a custom property is a good way to "discriminate".
Code: Select all
repeat with i = 1 to the number of fields of this cd
if the cDB of fld i is not empty then
---update database
end if
end repeat
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Get the names of all object type within a group
I've seen a few people use a similar flag in the object name, in which label fields (those not containing record content) begin with "lbl".bangkok wrote:You could use as well custom properties, that would contain the name of the column and be used as a "flag" (to know for instance if the field must be "emptied" before to display another record)
In my own work, most label fields are simply named "lbl", and where I may need to address them individually (such as for handling layouts in a resizeStack handler) I'll append something meaningful after the "lbl"; for example, next to a field named "Notes" I may have a label named "lblNotes".
Either custom props or naming conventions is useful, but one thing I've found handy with using a naming convention for label fields is that when looking at a list of control names such as in the Project Browser I can readily identify the field labels.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn