Get the names of all object type within a group

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Get the names of all object type within a group

Post by buchacho » Sat Jun 21, 2014 12:37 am

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?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Get the names of all object type within a group

Post by Simon » Sat Jun 21, 2014 12:55 am

Hi buchacho,
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
Simon :D
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!

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Get the names of all object type within a group

Post by bangkok » Sat Jun 21, 2014 3:13 pm

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)

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
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".

FourthWorld
VIP Livecode Opensource Backer
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

Post by FourthWorld » Sat Jun 21, 2014 3:41 pm

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)
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".

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

Post Reply