home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Prograph Classic 2.6.1 / Prograph Tutorial Manual / Prograph Tutorial / Prograph Tutorial.rsrc / TEXT_143.txt < prev    next >
Encoding:
Text File  |  1995-10-16  |  3.5 KB  |  71 lines

  1.  Challenge #5
  2.  
  3. Your Objective: Your final challenge is the toughest. Sort the scroll list of names in alphabetical order.*27**991*
  4.  
  5. Tips and Hints
  6.  
  7. q There are many ways to sort a list. In Prograph, most sorting algorithms*993* use list, loop, and partition *199*control annotations on roots and terminals. *138*Case structure also comes into play on certain sorts.
  8.  
  9.  If you are an experienced programmer and want a real challenge, write your sort method from scratch. Otherwise, use Selective Load *972*to bring the sort names universal method in from the Grand Tour Solutions file, located in the in the Ch 3 Δí folder within the Tutorial Examples Δí folder. This method performs a*115**992* bubble sort using a mixed list and loop multiplex Local operation. The local uses a comparison test to determine which of its two cases to perform.
  10.  
  11.  Determine the input and output requirements of sort names and work it into the Update the Name List local method in the Add method.
  12.  
  13. q Sorting the name list before setting the value list attribute of the *155*scroll list makes the value list order differ from the order of Person objects in People. So don‚Äôt forget to modify the Name List click method. You need to use the integer input to phoneNumber to extract the name string from value list. Then search the People list for a Person object with a name attribute that matches the name selected in the scroll list. (A current limitation of this implementation is that it assumes unique names.)
  14.  
  15. q The*370* find-instance *839*primitive is useful in locating a Person instance in the People persistent list given the individual‚Äôs name.
  16.  
  17. Solution to Challenge #5
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. Solution Comments: This challenge has two distinct parts. The first is to sort the name list. If you wrote your own sort method, congratulations. If you selectively loaded the sort names universal method as suggested, you can learn much about multiplex behavior by running Folks Database with Trace mode on. Inspect the list inputs and outputs as sort names executes. If your list of names is long, you may want to abort *8*execution and turn Trace back off‚Äîyou may be amazed at how many operations execute to sort a list.
  63.  
  64. The second task is to adjust your phoneNumber method and phone dialog local method such that you retrieve the correct Person object, since the scroll list and People list are no longer in the same order. To make this work, you have to use all three inputs to the phoneNumber click method. Get the value list from the incoming Scroll List object and use the incoming integer to extract the name string selected in the Name List pane. This name string is then passed into phone dialog. The phone dialog method must be modified to use the*371* *840*find-instance primitive to look for a Person object with a name attribute equal to the string input from phoneNumber.
  65.  
  66. t The Journey‚Äôs End
  67.  
  68. You have now completed the Grand Tour.
  69.  
  70. By working your way through the Grand Tour chapters, you have been introduced to a wide range of the features of Prograph. You have experienced the basics of the Prograph language and some of the powerful features that distinguish object-oriented and dataflow programming from traditional software development. You have developed an application with Prograph‚Äôs Application Builder, used its powerful editors and challenged your understanding with application enhancements. To enrich your understanding of Prograph, continue on to chapter 4, ‚ÄúConceptual Foundations,‚Äù and Part 2, ‚ÄúTutorials.‚Äù
  71.