scott@spectra.com (Tim Scott) (06/03/91)
Apologies in advance if this is an idiotic question.  I haven't found
the answer in Danny Goodman's book, the HyperTalk reference or by 
trying things on the system.
Why does a construction of this form work:
	repeat with cardNo = 1 to 10
	get field 1 of card cardNo of bg "Background"
but this doesn't
	repeat with cardNo = 1 to 10
	put id of card cardNo of bg "Background" into thisCard
	get field 1 of thisCard
(the reason I want to do this is so I can use thisCard several times
during the loop.)  It seems to work if I don't include the bg 
specifier, but I need to include it since I am stuffing fields from
bg "a" into a card belonging to bg "b".
Thanks in advance!
Tim Scott
Internet: scott@spectra.com     -or-    ...{ucsd!}nosc!spectra!scott 
AppleLink: SCOTT.T     America OnLine: TimS45       USA+619-587-6834ericg@ucschu.ucsc.edu (Eric Goodman) (06/04/91)
> repeat with cardNo = 1 to 10 > get field 1 of card cardNo of bg "Background" In this code you are talking about the NUMBER of the card > repeat with cardNo = 1 to 10 > put id of card cardNo of bg "Background" into thisCard > get field 1 of thisCard here you are using the ID of the card. Hypercard distinguishes between the ID and the NUMBER. The number of a card is simply where it is compared to the first card of the stack. As you add and delete cards, the number of each card changes. The ID of a card is a unique number that never changes no matter how other parts of the stack are modified. In general, the ID is a 4 to 5 digit number, so 1 to 10 probably don't even exist in your stack (I don't know why this is so). Generally you use the number of the card to go through a list of cards, and the ID to pick out a specific card. To get your example to work, use: repeat with cardNo = 1 to 10 put NUMBER of card cardNo of bg "Background" into thisCard get field 1 of thisCard The caps in number are for emphasis only. Happy scripting. Eric Goodman, UC Santa Cruz ericg@ucschu.ucsc.edu or @ucschu.bitnet Eric_Goodman.staff@macmail.ucsc.edu
M.Howlett@lut.ac.uk (Margaret Howlett) (06/04/91)
Sorry I can't do a follow up in the proper manner.  I'm new to this news
reading and haven't found out yet how to recall articles once I've read them
and printed them off for reference!
In response to scott@spectra.com, I agree that you SHOULD be able to do 
whathis second example is attempting but, it seems, you have to trick (or
kick!)
HyperCard into doing what is required here by making a couple of slight
alterations to the commands as follows:
										put SHORT id of card cardNo of bg "Background" into thisCard
          get field 1 of CARD ID thisCard
This works! I've tried it. Why it is necessary, I don't know.
If you use "put id of card........ into thisCard", thisCard will hold
"card id <4-digit integer>" so you would think that the words "card id"
would not be necessary on the following line.
Using "put short id .......... into thisCard" puts just the 4-digit integer
into thisCard so "card id" needs to be included on the next line.  Crazy!
In response to the followup article from ericg@ucschu.ucsc.edu, surely
"NUMBER of card cardNo" IS cardNo which would make the second example a
variation of the first and, therefore, not what is wanted.
Cheers!
Margaret Howlett, Dept. Computer Studies, 
Loughborough University of Technology, UKfwb@pollux.tmc.edu (Fred Brehm) (06/04/91)
Someone@spectra.com (I lost the attribution) asks why this does not work: > repeat with cardNo = 1 to 10 > put id of card cardNo of bg "Background" into thisCard > get field 1 of thisCard Eric Goodman asks suggests changing it to: > repeat with cardNo = 1 to 10 > put NUMBER of card cardNo of bg "Background" into thisCard > get field 1 of thisCard An alternative way is: repeat with cardNo = 1 to 10 put SHORT id of card cardNo of bg "Background" into thisCard -- SHORT might not be necessary, but I always code it this way. get field 1 of CARD ID thisCard I think that accessing the card by ID is the fastest way to get to it, but the other way will work, too. Fred -- Frederic W. Brehm Siemens Corporate Research Princeton, NJ fwb@demon.siemens.com -or- ...!princeton!siemens!demon!fwb
bcarter@claven.idbsu.edu (Bruce Carter) (06/05/91)
In article <1991Jun3.165716.17483@spectra.com> scott@spectra.com (Tim Scott) writes: >Why does a construction of this form work: > > repeat with cardNo = 1 to 10 > get field 1 of card cardNo of bg "Background" > >but this doesn't > > repeat with cardNo = 1 to 10 > put id of card cardNo of bg "Background" into thisCard > get field 1 of thisCard > I think you may have run into a limitation of the interpreter/compiler in HyperCard. Try using a "do" construction on your last line and you should be able to get it to work. Something along the lines of: put "get field 1 of" && thisCard into myCommand do myCommand Bruce Carter Internet: bcarter@claven.idbsu.edu Courseware Development Coordinator duscarte@idbsu.idbsu.edu Boise State University Bitnet/CREN: duscarte@idbsu