grab the names of all fields

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

grab the names of all fields

Post by adventuresofgreg » Fri Oct 19, 2012 2:03 pm

Hello: Is there a way to grab the names of every single field in a stack?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: grab the names of all fields

Post by dunbarx » Fri Oct 19, 2012 2:07 pm

Sure. Write a short script that navigates to each card (I assume there are different fields on those cards) and collects the field name info on each.

The script ought to be about eight lines. This will be terrific practice, since you will be using two nested repeat loops. (hint)

Do you need help doing this? Write back if you need me to do it, but you should try first.

Craig Newman

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: grab the names of all fields

Post by Thierry » Fri Oct 19, 2012 2:11 pm

adventuresofgreg wrote:Hello: Is there a way to grab the names of every single field in a stack?

Here is some code :

on mouseUp
local tmp
repeat with i=1 to the number of fields of this card
put the short name of field i &cr after tmp
end repeat
put tmp
end mouseUp

HTH

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: grab the names of all fields

Post by adventuresofgreg » Fri Oct 19, 2012 4:55 pm

oh ya - use the field number. duh. I'm so used to ref field names, I forget they are sequentially numbered. Thanks. I'm writing a handler to save the state of a standalone to file - probably a cloud based file. I write the contents of every field, and state of each button, etc to an array and dump it into a file - then on open, read that array back in, and fill-in fields, and set buttons etc.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: grab the names of all fields

Post by dunbarx » Fri Oct 19, 2012 7:12 pm

Hi.

Well and good, then.

Remember. The three main identifying properties of an object, and this dates back to 1987, are the name, number and id. LC has others for certain classes of objects, but these three should be able to handle any possible contingency. They each have their own special attributes. Make sure you know what the id can and cannot do.

Craig Newman

Post Reply