referring to a field that is part of a group

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Alistair
Posts: 33
Joined: Mon Jun 23, 2008 6:45 am

referring to a field that is part of a group

Post by Alistair » Fri Oct 10, 2008 10:57 am

This seems like a really basic question but I can't find an explanation anywhere: how does one refer to a field that is part of a group.

I have a number of text fields grouped and the group is then used as a background extending across several cards. I want to be able to read the contents of a specific field on a specific card and transfer the contents to a variable. Presumably it is not necessary to ungroup the fields, read the specific field and then regroup.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Fri Oct 10, 2008 11:28 am

Hi Alistair,

you already have the answer in your question:

Code: Select all

...
put fld "your field in a group here" of cd "whatever" into field_var
...
If you do not have several fields with the same name on a card (you would never do so, right? ;-)) then you don't even need to specify the groups name.

Definitvely NO need to ungroup or other tricky procedures :-)

Hope that helps.


Best

Klaus

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Fri Oct 10, 2008 1:01 pm

If your field is part of a group woth backgroundbehaviour, you'll have to first 'go' to that specific card - otherwise you get the data from that same field as displayed on the current card. Preferably wrap this 'go' inside a lock/unlock screen pair to avoid that the user sees the change in cards.

Code: Select all

on mouseUp
  lock screen
  go card 2
  put field "Foobar" into tData
  go back
  unlock screen
  answer tData
end mouseUp
HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Fri Oct 10, 2008 1:09 pm

Sorry, Jan, but this is really not necessary!

You can simply do as I wrote in my first anwer:

Code: Select all

... 
put fld "your field in a group WITH BG behaviour here" of cd "whatever" into field_var 
...
Just tested and works :-)

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Sat Oct 11, 2008 6:38 am

Now I remember what my problem in this regard was - it was in the context of the 'value' function: http://quality.runrev.com/qacenter/show_bug.cgi?id=1836

Anyway, carry on, nothing to see here - Klaus was right from the start and I was making things more complicated because of a corner case... :-)

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Alistair
Posts: 33
Joined: Mon Jun 23, 2008 6:45 am

Post by Alistair » Sun Oct 12, 2008 2:33 am

Thanks for those tips. I have set up the cards with the same background and my script working perfectly. I tried a few possibilities before posting my message but didn't quite get the syntax right.

Post Reply