[comp.sys.mac.hypercard] "Repeat with...." question

boz@eleazar.Dartmouth.EDU (John Boswell) (02/23/88)

Hi.  I am a little stumped, so I figured I'd ask the net...
	I wrote a nifty (I think 8-) ) stack for keeping track of my music col-
lection and one to keep track of my library.  One of the buttons in each stack 
looks at all the cards and determines which items at any particular time are
out on loan to someone.  This can be useful if I need to "recall" a book or 
cd, or whatever, or to remind someone to return something they borrowed 6 monthsago..

My problem is that the button contains the following script: (in part)

repeat with the number of cards of this bkgnd

...do the checking

end repeat

	Problem is, this doesn't work, and HC chokes on the "of this bkgnd".
For my music stack this isn't a major problem... I only have one bkgnd,
so I just took out the "of this bkgnd" part of the button script.  that works
fine.  However, I have TWO backgrounds in my library stack... taking out the 
"of this bkgnd" results in the button repeating for the number of cards in
the ENTIRE stack!  Needless to say, this results in say, a single item on
loan being "found" and reported too many times!
	I tried changing to "with this bkgnd" or "in" or etc., ad nauseum, to
no avail.  Can anybody tell me how to only repeat for the number of cards
in a single background???  Alternately, how do I determine the "number of
cards in bkgnd "X" "???

thanks for any info...

John Boswell
Department of Chemistry
Dartmouth College
Hanover, Nude Hampster  03755
Department of Chemistry
boz@eleazar.dartmouth.edu

edmoy@violet.berkeley.edu (02/25/88)

In article <8232@eleazar.Dartmouth.EDU> boz@eleazar.Dartmouth.EDU (John Boswell) writes:
>	I wrote a nifty (I think 8-) ) stack for keeping track of my music col-
>lection and one to keep track of my library.  One of the buttons in each stack 
>looks at all the cards and determines which items at any particular time are
>out on loan to someone.  This can be useful if I need to "recall" a book or 
>cd, or whatever, or to remind someone to return something they borrowed 6 monthsago..
>
>My problem is that the button contains the following script: (in part)
>
>repeat with the number of cards of this bkgnd
>
>...do the checking
>
>end repeat
>
>	Problem is, this doesn't work, and HC chokes on the "of this bkgnd".

Yes, the "the number of cards" construct only works for the total number
of cards in the stack, so you can't modify it with "of this bkgnd".

>	I tried changing to "with this bkgnd" or "in" or etc., ad nauseum, to
>no avail.  Can anybody tell me how to only repeat for the number of cards
>in a single background???  Alternately, how do I determine the "number of
>cards in bkgnd "X" "???

Try something like this:

go first card of bkgnd "Whatever"
put short id of this card into firstCard
...do the checking
go next card of this bkgnd
repeat until short id of this card is firstCard
  ...do the checking
  go next card of this bkgnd
end repeat

This should work but is on the slow side.  If you have a field on the cards
that contain the date the book was loaned out, and empty otherwise, then
you can search for something like a comma in that field.

go first card of bkgnd "Whatever"
find chars "," in field "Loaned Date"
if the result is not empty then
  ... nothing on loan
end if
put short id of this card into firstCard
...do whatever
go next card of this bkgnd
find chars "," in field "Loaned Date"
repeat until short id of this card is firstCard
  ...do whatever
  go next card of this bkgnd
  find chars "," in field "Loaned Date"
end repeat

This is much faster if most of your library isn't loaned out.

Edward Moy
Workstation Software Support Group
University of California
Berkeley, CA  94720

edmoy@violet.Berkeley.EDU
ucbvax!violet!edmoy

sysop@stech.UUCP (Jan Harrington) (02/27/88)

in article <8232@eleazar.Dartmouth.EDU>, boz@eleazar.Dartmouth.EDU (John Boswell) says:
> 
> Hi.  I am a little stumped, so I figured I'd ask the net...
> 	I wrote a nifty (I think 8-) ) stack for keeping track of my music col-
> lection and one to keep track of my library.  One of the buttons in each stack 
> looks at all the cards and determines which items at any particular time are
> out on loan to someone.  This can be useful if I need to "recall" a book or 
> cd, or whatever, or to remind someone to return something they borrowed 6 monthsago..
> 
> My problem is that the button contains the following script: (in part)
> 
> repeat with the number of cards of this bkgnd
> 
> ...do the checking
> 
> end repeat
> 
> 	Problem is, this doesn't work, and HC chokes on the "of this bkgnd".
> For my music stack this isn't a major problem... I only have one bkgnd,
> so I just took out the "of this bkgnd" part of the button script.  that works
> fine.  However, I have TWO backgrounds in my library stack... taking out the 
> "of this bkgnd" results in the button repeating for the number of cards in
> the ENTIRE stack!  Needless to say, this results in say, a single item on
> loan being "found" and reported too many times!

Sometimes you have to put a quantity into a container all of its own to use
it in a repeat statement.   Try something like:

put the number of cards of this background into NumbCards
repeat with NumbCards ...


end repeat


Jan Harrington, sysop
Scholastech Telecommunications
UUCP: ihnp4!husc6!amcad!stech!sysop or allegra!stech!sysop
BITNET: JHARRY@BENTLEY

********************************************************************************
	Miscellaneous profundity:

		"No matter where you go, there you are."
				Buckaroo Banzai
********************************************************************************

winkler@Apple.COM (Dan Winkler) (02/29/88)

There is no such thing as "number of cards in <bkgnd>" yet.  The
"number of cards" function assumes you mean the number of cards in the
whole stack.  There is no way to determine how many cards there are in
a particular background without stepping through and counting them.

As it happens, I spent yesterday at Bill's house adding a few new
features, one of which was "number of cards in <bkgnd>".  Don't ask me
when this will ship or what else will be new because I can't talk about
either topic.

Dan.

john@felix.UUCP (John Gilbert) (03/02/88)

>> 
>> My problem is that the button contains the following script: (in part)
>> 
>> repeat with the number of cards of this bkgnd
>> 
>> ...do the checking
>> 
>> end repeat
>> 
>
>Sometimes you have to put a quantity into a container all of its own to use
>it in a repeat statement.   Try something like:
>
>put the number of cards of this background into NumbCards
>repeat with NumbCards ...
>
>
>end repeat
>


Several folks have pointed out that "the number of cards in this background"
may not be supported yet.  I have not confirmed this, and it may very well
be true.  However, there is a more basic problem in the original example
not yet mentioned:

The "repeat with..." is to be used with a varible counter the same way
a for loop is traditionally used.  It might help to change the repeat loop
to:

  repeat for <value>

  end repeat

to see if this produces the desired results.

John Gilbert
--
John Gilbert
!trwrb!felix!john