CSE 203 Homework 1

You may complete this homework, as any homework in this course, either alone as an individual, or in partnership with one other person.  Please make sure every author's name is listed at the top.
  1. Complete Closed Lab 1 if you haven't already done so.
  2. Continue experimenting with Display_a_Window.kpl according to the following instructions.  Write (or print) out answers to all questions asked (16, 17, 18, 20, and 24).
  3. If you've just started Phrogram again and loaded Display_a_Window.kpl, then you probably don't yet see the body of Method Main()!  Just click on the plus sign appearing to the left of Method Main() to open the body of Main() so you can see it and edit it.  Insert a new line into the program just above the line that starts with "Status".  This new line should look like the following:
    Trace( "Out of sight!  This program has started running!" )
  4. If you wish, you can also change "Our first Phrogram program" to "A Phrogram program".
  5. Run (which automatically saves) this changed program.
  6. Look in the Messages sub-window to see the effect of method Trace().  Note that programmers call commands like Status() and Trace() "methods", and that they often place an empty pair of parentheses after the method's name when they're writing about a program to indicate to their reader that it is the name of a method (or of a function).  A function is similar to, but different than, a method, but more on that later.
  7. Close the stopped program's window.
  8. Programmers often wish to experiment with a program by, say, removing one or more lines from the program.  However, they may later wish to put one or more of those lines back in.  They can accomplish this task efficiently by "commenting out" the lines to be (temporarily) removed.  That is to say, they turn these lines into comments.  Later, they can remove the comment symbols to put those lines back in the program.  These actions are so handy that this ability is built into many IDEs, including Phrogram's.
  9. Comment out the line beginning with "Status" by dragging the mouse from the beginning of Status to the end of the line.  Then, on the toolbar, click the button image of the comment-out button that has horizontal lines in it, some black and some light blue.
  10. Run this changed program and observe what's different.
  11. Now uncomment the line beginning with "Status" to put it back into the program.  Do this by dragging the mouse from the beginning of the comment to the end of the line.  Then, on the toolbar, click the button image of uncomment button that has the curving arrow in it.
  12. Run this program and note that it now behaves just as it did before you commented out the line beginning with "Status".
  13. Now insert two new lines into the program just after the line that starts with "Status".  These new lines should look like the following:
    Alert( "Click OK to continue.  This program run is about to end.", "Good-bye!" )
    Trace( "Program ends, but window stays open." )
  14. If you wish, you can also change "A Phrogram program" to "Mission accomplished!".
  15. Run this changed program.
  16. Before clicking on OK to continue, look at the window containing the OK button.  Can you find the text "Good-bye!"?  Look everywhere!  Tell me where it is.
  17. Now look in the Messages window.  Have all messages from calls to method Trace() come out yet?
  18. What do you conclude about the order in which a programmer lists calls to methods?  Does the order matter?  If so, how?
  19. As you can probably guess from 17. and 18. above, when a programmer mentions a method, she says she "calls" it.  "Hello?  Is Status there?  Hi Status!  Could you please put this message on the bottom of the application window?"  In the current program, method Main() consists of a list of four method calls.
  20. Now click OK to continue and look again in the Messages window.  Is your conclusion about the order of method calls in a list confirmed by what you see?  Well, it happens pretty fast.  Try to notice what's there before you click OK and what's there afterward.  After closing the stopped program's window, run the program again if you need to!
  21. Close the stopped program's window.
  22. Replace the last two of the four method calls in Main() with the following four calls:
    Alert( "Click OK to continue.  This window will close.", "Good-bye!" )
    Trace( "Closing window . . ." )
    Stop()
    Trace( "This message should not appear!" )
  23. Run this changed program, carefully observing its behavior.
  24. What do you infer the behavior of method Stop() to be?
  25. Now close Display_a_Window.kpl by right-clicking on its tab and selecting Close from the list.
  26. Now open a different pre-existing program by performing the following steps:
    1. In the Files view in the right-hand side of the window, open folder "OSU" by double clicking on it.
    2. Find file "001 Display_a_Window.kpl" and open it by double clicking on it.
  27. Notice in this program that there are many comments, some of them rather long.  It can become rather tedious to type "//" as the first characters of every line of a long comment.  Hence one other way of denoting comments is available in Phrogram programs.  Before reading ahead, can you guess by looking at this program what that way is?
  28. That's right: "/*" marks the beginning of a comment; that comment comes to an end with "*/".
  29. You should now be able to open Display_a_Window.kpl again by finding it in the "0) My Own" folder.
  30. Now you have two tabs open in Phrogram.  You can switch back and forth between these programs by clicking on their tabs.
  31. You can now close the longer file "001 Display_a_Window.kpl", the one with all those many comments, by right-clicking on its Display_a_Window.kpl tab and selecting "Close all other programs".
  32. You could have exited Phrogram with two or more tabs up, or with zero tabs up.  However, why not exit Phrogram now with one tab up?  In any case, the next time you launch Phrogram, it will come up with the same number of tabs open as when you left it.
  33. Read the syllabus, and bring to class any questions you have about it.
  34. Congratulations upon finishing all 34 steps of Homework 1!  Whenever you wish, feel free to experiment with Phrogram as much as you want.  (For example, what happens when you comment out some other lines of the program, such as the "Program" line or an "End Method" line?)  Also, if you want to get excited about what you could do with Phrogram later in the course, please visit http://www.phrogram.com.