alice-teacher Problems with looping in Alice 3 - s Digest, Vol 45, Issue 9

Robert Durtschi robert.durtschi at gcsu.edu
Tue Apr 8 12:43:26 EDT 2014


Have you displayed number and it shows 4?
Alice 2 (and Alice 3 too, I'm sure) has a print you can drag to the edit window.
You'll also want to display number within the while loop to verify it's decrementing.  Something like this:

  print(  number  ); 
  while (  number > 0 )  { 
       //  do some flashy light stuff 
      number = number - 1 ;    // ( or  number-- ; )
      print(  number  );  
  } 
  print(  "done" );


It could be that the variable has a strange initial value. If, for instance it read the number that was typed as an ASCII (Unicode) 52  instead of the number 4. With the initial print you can tell that it is set to the value you expect it to be set to. 

It could be that the variable is being modified somewhere else within the loop.  By printing it at the bottom of the loop you can get an idea of whether it's decrementing properly.

Best
Bob Durtschi
________________________________________
From: alice-teachers-bounces+robert.durtschi=gcsu.edu at lists.andrew.cmu.edu <alice-teachers-bounces+robert.durtschi=gcsu.edu at lists.andrew.cmu.edu> on behalf of alice-teachers-request at lists.andrew.cmu.edu <alice-teachers-request at lists.andrew.cmu.edu>
Sent: Tuesday, April 08, 2014 12:00 PM
To: alice-teachers at lists.andrew.cmu.edu
Subject: alice-teachers Digest, Vol 45, Issue 9

Send alice-teachers mailing list submissions to
        alice-teachers at lists.andrew.cmu.edu

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers
or, via email, send a message with subject or body 'help' to
        alice-teachers-request at lists.andrew.cmu.edu

You can reach the person managing the list at
        alice-teachers-owner at lists.andrew.cmu.edu

When replying, please edit your Subject line so it is more specific
than "Re: Contents of alice-teachers digest..."


Today's Topics:

   1.  Problems with looping in Alice 3 (Terri Logan)


----------------------------------------------------------------------

Message: 1
Date: Mon, 7 Apr 2014 21:21:37 -0400
From: Terri Logan <tlogan at msmacademy.org>
Subject: alice-teacher Problems with looping in Alice 3
To: "alice-teachers at lists.andrew.cmu.edu"
        <alice-teachers at lists.andrew.cmu.edu>
Message-ID: <B1A8691B-DA50-4C68-92D5-567B0ACF240D at msmacademy.org>
Content-Type: text/plain; charset="us-ascii"

> I have this game, its a mimic of the game Simon, where there are 4 object that randomly blink and play a tone.
> I've decided I want my user to decide what level they will play of this game, so I ask the user for a level, and store that number in a variable.  I've tried every loop there is, and for the life of me I cannot get it to work right.
> I thought I had it with while (number>0){play 1 of 4 tones, decrement number} but it just keeps going, I've counted up to 20, but I assume an infinite loop.
> When using the count, it plays each tone as many times as the number I entered and is equal to the count.
>
> Any guidance is greatly appreciated.
>
> --
> Terri Logan
> System Administrator
> Mount St. Mary Academy
> tlogan at msmacademy.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20140407/701f01ed/attachment-0001.html

------------------------------

_______________________________________________
alice-teachers mailing list
alice-teachers at lists.andrew.cmu.edu
https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers


End of alice-teachers Digest, Vol 45, Issue 9
*********************************************


More information about the alice-teachers mailing list