home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v1.2 / amidev_cd_12.iso / reference / amiga_mail_vol1 / program / fivealive < prev    next >
Text File  |  1990-01-26  |  3KB  |  66 lines

  1. (c)  Copyright 1989 Commodore-Amiga, Inc.   All rights reserved.
  2. The information contained herein is subject to change without notice, and 
  3. is provided "as is" without warranty of any kind, either expressed or implied.  
  4. The entire risk as to the use of this information is assumed by the user.
  5.  
  6.  
  7.               Five Alive (Or How to Help Your Program Survive)  
  8.    
  9.                               by Dan Schein
  10.  
  11.  
  12. Below is our Programmer's Guide to Well-Formed Amiga Code.  Writing for the
  13. Amiga takes a little advance planning in order to work right with the OS and
  14. take full advantage of multi-tasking.  Following these five suggestions will
  15. keep your program out of trouble and the user from wanting a refund.
  16.  
  17.  
  18. 1. Do not tie up resources unnecessarily.
  19.  
  20.     The two most commonly abused resources are the printer and memory.
  21.     Only open a resource when you need it. This will allow other
  22.     programs to use the same resources while your program is running.
  23.  
  24. 2. Free up any allocated resources when exiting the program.
  25.  
  26.     This is very important for both normal program exit and termination
  27.     due to an error. The best method is to have a single cleanup routine
  28.     that frees all resources that were used by the program. This clean up
  29.     should test the return value of each item your program opened/allocated
  30.     and then close/deallocate those with valid values in the reverse order
  31.     of original allocation.
  32.  
  33. 3. Make sure requested resources are obtained. If not - exit gracefully.
  34.  
  35.     If a requested resource is not obtained and a attempt is made to
  36.     use that resource, a unfriendly visit from the guru is the result.
  37.     Note that this includes required library versions, memory
  38.     allocations, windows, screens, file handles, devices, ports, etc.
  39.     If your program requires functions or features not available under
  40.     an earlier version of the OS, be sure to specify the version you need
  41.     in your OpenLibrary() call.  Remember to inform the user which version
  42.      of the OS is required in the manual or on the box.
  43.  
  44.                     0    any version is ok
  45.                     30    1.0 or higher
  46.                     31    1.1 NTSC or higher
  47.                     32    1.1 PAL or higher
  48.                     33    1.2 or higher
  49.  
  50. 4. Do not tie up the CPU. Do not use 'busy waits' - use Wait().
  51.  
  52.     When waiting for external events like menu selection or key presses,
  53.     programs should go to sleep by Wait()ing for a signals. This will
  54.     allow other programs to run while yours is waiting. When your program
  55.     is awakened it should check for messages at each port whose signal bit
  56.     was set. Remember that there may be more than one message per port.
  57.     Also you should ReplyMsg() to all messages that are not reply messages
  58.     themselves.
  59.  
  60. 5. Do not assume a system configuration. 
  61.  
  62.     By checking a system's configuration and not assuming any specific
  63.     configuration you could save both you and the user a lot of headaches.
  64.     For instance, the second drive on many A2000s is designated df2:
  65.     instead of df1:.
  66.