Get data from field in card1 and put into var in card2

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
daryl
Posts: 47
Joined: Mon Apr 29, 2013 11:43 pm

Get data from field in card1 and put into var in card2

Post by daryl » Fri Jun 07, 2013 10:36 pm

Hi Folks,

I've been trying to find this in the docs and tutorials, without success, so I'm hoping someone here can help.
I a stack with several cards, let's call them card1 and card2. While in card2 I need to get the value of a field
in card1 and put it into a container in the current card, i.e. card2. I know I can do a goto card "card2", but
am hoping to find how to do this without having to "go" there. I've tried the following without any luck:

put text from field "Field 1" of card "Card1" into myContainer
get text from field "Field 1" of card "Card1" and put it into myContainer

Any help, pointer to documentation,etc. would be much appreciated.

Thaks,

Daryl

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

Re: Get data from field in card1 and put into var in card2

Post by dunbarx » Fri Jun 07, 2013 10:48 pm

Hi.

You have the feel of LC syntax, but not quite the syntax itself.

No "from". Use "of".

Look up "of" and "in" in the dictionary. Sometimes redundant keywords are allowed, (as "in" and "of"). But not "from".

Craig Newman
Last edited by dunbarx on Fri Jun 07, 2013 10:52 pm, edited 1 time in total.

makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Re: Get data from field in card1 and put into var in card2

Post by makeshyft » Fri Jun 07, 2013 10:50 pm

put the field "fieldname" of the card "mycard" into the field "fieldname2"of the card "second card"

this should work.
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

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

Re: Get data from field in card1 and put into var in card2

Post by dunbarx » Fri Jun 07, 2013 11:01 pm

Makeshyft.

I think too many "the's":

put the field "fieldname" of the card "mycard" into the field "fieldname2"of the card "second card"

really ought to just be:

put field "fieldName" of card "myCard" into field "fieldName2" of card "secondCard" --never mind "field" to "fld" and "card" to "cd"

There was an important thread recently about the looseness of keyword use in LC. This is a holdover from the Hypercard legacy. The keyword "the" itself was the issue, mainly as it related to references to properties and especially custom properties. I feel the keyword "the" should only be used with properties (it is required for custom ones), function calls without parentheses, and never anywhere else. In this script it is merely superfluous. It can get you in trouble, however.

Craig Newman
Last edited by dunbarx on Fri Jun 07, 2013 11:09 pm, edited 1 time in total.

daryl
Posts: 47
Joined: Mon Apr 29, 2013 11:43 pm

Re: Get data from field in card1 and put into var in card2

Post by daryl » Fri Jun 07, 2013 11:06 pm

Thanks guys,

Both suggestions worked! Much appreciated. I tried both:

put the field "Field1" of the card "Card1" into myContainer
put the text of field "Field1" of card "Card1" into myContainer

and ended up using the second form as it seemed the most expressive, even if a tad longer.

Regards,

Daryl

Post Reply