How to put data into field of same name on many cards

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
CAsba
Posts: 364
Joined: Fri Sep 30, 2022 12:11 pm

How to put data into field of same name on many cards

Post by CAsba » Wed Mar 08, 2023 3:39 pm

Hi,
On many of the cards in my project I have a header field, 'header', that displays the name of the User's business. Is there a way of putting the name (compnamex) into all the fields named 'header' in the project (some to be created at a future date) ?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to put data into field of same name on many cards

Post by dunbarx » Wed Mar 08, 2023 4:13 pm

CAsba

Not exactly sure how you are populating fields going forward, but there are two things you should experiment with.

1- Know that if you group a field and set its "backGroundbehavior" to "true" then every new card you create will also contain that field.

2- If you set the "sharedText" property of that field then every instance of that field on every card will be the same.

You can fool around with these sorts of things, setting and unsetting properties to see how things change.

Craig

CAsba
Posts: 364
Joined: Fri Sep 30, 2022 12:11 pm

Re: How to put data into field of same name on many cards

Post by CAsba » Wed Mar 08, 2023 5:21 pm

Thank you Craig, sounds like just what I needed.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to put data into field of same name on many cards

Post by dunbarx » Wed Mar 08, 2023 5:46 pm

CAsba.

There is much to play with when setting and unsetting the "sharedText" property. This goes all the way back to Hypercard.

Make a stack with a field. Group the field, and set the group backGroundbehavior to "true". Now set the sharedText of the field itself to "true". Put a word or two in that field.

Now make a few new cards. You will find that the field on each card has the same text.

Now set the sharedText of the field to false, and put different text in each field on each card. Cycling through the cards, you see that each field has its own text. Now set the sharedText to "true". You will see that each field now shares the text of the field on the card that was in front when you set that property. If you then set that property to "false" you will see that each field reverts back to its own individual text. The field "remembers" both values, and which one to display depending on the state of the sharedtext property.

With careful management, this has always been a very cool feature.

Craig
Last edited by dunbarx on Thu Mar 09, 2023 3:35 pm, edited 1 time in total.

CAsba
Posts: 364
Joined: Fri Sep 30, 2022 12:11 pm

Re: How to put data into field of same name on many cards

Post by CAsba » Thu Mar 09, 2023 12:04 pm

Hi Craig,
That's great..I did it and it worked !
Many thanks.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”