Page 1 of 1

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

Posted: Fri Jun 07, 2013 10:36 pm
by daryl
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

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

Posted: Fri Jun 07, 2013 10:48 pm
by dunbarx
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

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

Posted: Fri Jun 07, 2013 10:50 pm
by makeshyft
put the field "fieldname" of the card "mycard" into the field "fieldname2"of the card "second card"

this should work.

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

Posted: Fri Jun 07, 2013 11:01 pm
by dunbarx
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

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

Posted: Fri Jun 07, 2013 11:06 pm
by daryl
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