home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Developer CD v1.2
/
amidev_cd_12.iso
/
reference
/
amiga_mail_vol1
/
program
/
fivealive
< prev
next >
Wrap
Text File
|
1990-01-26
|
3KB
|
66 lines
(c) Copyright 1989 Commodore-Amiga, Inc. All rights reserved.
The information contained herein is subject to change without notice, and
is provided "as is" without warranty of any kind, either expressed or implied.
The entire risk as to the use of this information is assumed by the user.
Five Alive (Or How to Help Your Program Survive)
by Dan Schein
Below is our Programmer's Guide to Well-Formed Amiga Code. Writing for the
Amiga takes a little advance planning in order to work right with the OS and
take full advantage of multi-tasking. Following these five suggestions will
keep your program out of trouble and the user from wanting a refund.
1. Do not tie up resources unnecessarily.
The two most commonly abused resources are the printer and memory.
Only open a resource when you need it. This will allow other
programs to use the same resources while your program is running.
2. Free up any allocated resources when exiting the program.
This is very important for both normal program exit and termination
due to an error. The best method is to have a single cleanup routine
that frees all resources that were used by the program. This clean up
should test the return value of each item your program opened/allocated
and then close/deallocate those with valid values in the reverse order
of original allocation.
3. Make sure requested resources are obtained. If not - exit gracefully.
If a requested resource is not obtained and a attempt is made to
use that resource, a unfriendly visit from the guru is the result.
Note that this includes required library versions, memory
allocations, windows, screens, file handles, devices, ports, etc.
If your program requires functions or features not available under
an earlier version of the OS, be sure to specify the version you need
in your OpenLibrary() call. Remember to inform the user which version
of the OS is required in the manual or on the box.
0 any version is ok
30 1.0 or higher
31 1.1 NTSC or higher
32 1.1 PAL or higher
33 1.2 or higher
4. Do not tie up the CPU. Do not use 'busy waits' - use Wait().
When waiting for external events like menu selection or key presses,
programs should go to sleep by Wait()ing for a signals. This will
allow other programs to run while yours is waiting. When your program
is awakened it should check for messages at each port whose signal bit
was set. Remember that there may be more than one message per port.
Also you should ReplyMsg() to all messages that are not reply messages
themselves.
5. Do not assume a system configuration.
By checking a system's configuration and not assuming any specific
configuration you could save both you and the user a lot of headaches.
For instance, the second drive on many A2000s is designated df2:
instead of df1:.