[comp.sys.mac.hypercard] on idle "backgrounding" & switch{}/CASE

borton@uva.UUCP (Chris Borton) (11/19/88)

Scenario: I've got one stack full of information cards on various
geographical locations in different fields.  A different stack, "Tester" goes
to the "Geography" stack and pulls pairs of fields at random to make a
match-the-pairs test.  Currently I have this done all at once via a button.

The complaint from the students is that this takes awhile.  I agree, and have
optimized it as much as I can, I think.  However, ideally I'd like to do the
whole process 'in the background' while they are busy thinking about the
current test.

I don't think this would be too hard, using an 'on idle' handler, but my
question is how to best implement it.  My initial thought is the have the
idler increment a variable and call a function with that variable, which
would tell it what to do.

Breaking the test-building process into chunks and doing them according to
the number passed seems fine; where the problem comes in is how to deal with
the number coming in and what to do--a CASE statement in Pascal, switch{} in C.

As far as I can tell, there is no clean way to do this in HyperTalk other
than ungainly masses of if/then levels.  If there is no better way, then I'll
probably end up doing that at several levels.  But I'd rather not.

Can anyone shed light on this?  Better solutions?

Thanks...

-cbb
-- 
Chris Borton	borton%uva@mcvax.{nl,bitnet,uucp} 
Rotary Scholar, University of Amsterdam CS
Now Palestine is a virtual country.  But what gets swapped out on page-fault?

martin@home.csc.ti.com (Steven Martin) (11/21/88)

In article <570@uva.UUCP> borton@uva.UUCP (Chris Borton) writes:
>Breaking the test-building process into chunks and doing them according to
>the number passed seems fine; where the problem comes in is how to deal with
>the number coming in and what to do--a CASE statement in Pascal, switch{} in C.
>
>As far as I can tell, there is no clean way to do this in HyperTalk other
>than ungainly masses of if/then levels.  If there is no better way, then I'll
>probably end up doing that at several levels.  But I'd rather not.

Since you are stuck with if/then levels, here is a hopefully helpful
tip on how to format then so that they don't indent to far.

The old way.

if ....
then ....
else
  if ....
  then ....
  else
    if....
    then
      .....
    end if
  end if
end if


The new way.

if ....
then ....
else if ....
then ....
else if ....
end if

Hope that helps!

Steve Martin            USENET: {ctvax,im4u,texsun,rice}!ti-csl!martin
                        GENIE: S.MARTIN8    PHONE: (214)-995-5919, 404-1061
What I am is what I am, are you what you are or what?
- Edie Brickell & THE New Bohemians

Scot.Kamins@f555.n125.z1.FIDONET.ORG (Scot Kamins) (12/02/88)

It all depends. Let's see the code. I'll bet it doesn't have to be an ungainly mass.


--  
Scot Kamins - via FidoNet node 1:125/406
UUCP: ...!sun!hoptoad!fidogate!555!Scot.Kamins
ARPA: Scot.Kamins@f555.n125.z1.FIDONET.ORG