home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / datafiles / text / c_manual / amiga / appendices / examples / systemexamples.doc < prev    next >
Text File  |  1995-02-27  |  6KB  |  165 lines

  1. 4    SYSTEM
  2.  
  3. 4.1  HARDWARE
  4.  
  5. Example 1
  6.  
  7.   This fantastic useful program does what all true hackers have
  8.   dreamt of. Enjoy your Amiga's fantastic ability to flash one
  9.   LED!
  10.  
  11. Example 2
  12.   This is a very bad program that plays a tune with the first
  13.   audio channel. The reason why it is bad is because the
  14.   program does not "lock" the channel before it uses the
  15.   hardware. It simply steals the sound channel without asking
  16.   nor notifying anyone.
  17.  
  18.   If you lock the channel as described in the Audio Device
  19.   chapter you may use the hardware registers. However, this
  20.   program does not lock it nor tries to reserve the channels
  21.   as we should. The program is included here only as a
  22.   demonstration how the hardware registers are working, but
  23.   should not be used in your own programs!!!
  24.  
  25.  
  26.  
  27. 4.2  AMIGADOS
  28.  
  29. Example1
  30.   This program collects ten integer values from the user, and
  31.   saves them in a file ("HighScore.dat") on the RAM disk. The
  32.   memory is then cleared, and the file cursor is moved to the
  33.   beginning of the file. The file is then loaded into the
  34.   memory again, and printed out.
  35.  
  36. Example2
  37.   This example demonstrates how to create a directory called
  38.   "MyDirectory" on the RAM disk.
  39.  
  40. Example3
  41.   This example demonstrates how to rename files and directories.
  42.   It will rename the file Example 1 created (called
  43.   "HighScore.dat") to "Numbers.dat". It will also rename the
  44.   directory Example 2 created ("MyDirectory") to "NewDirectory".
  45.  
  46. Example4
  47.   This example demonstrates how to delete files and directories.
  48.   It will delete the file Example 1 and directory Example 2
  49.   created. (The file and directory are supposed to have been
  50.   renamed by Example 3.)
  51.  
  52. Example5
  53.   This example demonstrates how to attach a short comment to a
  54.   file. A short file called "Letter.doc" will be created, and a
  55.   short comment will be attached. To see the comment use the
  56.   CLI command "List".
  57.  
  58. Example6
  59.   This example demonstrates how to protect and unprotect files.
  60.   The file Example 5 created ("Letter.doc") will be protected,
  61.   and we will then try to delete it (unsuccessfully). We will
  62.   then unprotect the file and then try to delete it
  63.   (successfully).
  64.  
  65. Example7
  66.   This program takes a file/directory/device name as
  67.   parameter, and prints out some interesting information about
  68.   it.
  69.  
  70. Example8
  71.   This program takes a directory/device name as parameter,
  72.   and prints out all the file/directory-names inside it. This
  73.   example describes how to use Examine() and ExNext().
  74.  
  75.  
  76.  
  77.  
  78. 4.3  LISTS
  79.  
  80. Example 1
  81.   Demonstrates how to create a list with three nodes. (Not very
  82.   amazing, but useful to know.)
  83.  
  84. Example 2
  85.   Demonstrates how to scan through a list from the head to the
  86.   tail, and the other way around.
  87.  
  88. Example 3
  89.   Demonstrates how to scan through a list looking for nodes with
  90.   a special name. Uses the function FindName().
  91.  
  92.  
  93.  
  94. 4.4  MESSAGES
  95.  
  96. Example 1
  97.   A: This program will create a message port called "NrPort".
  98.   It will then go to sleep and will first wake up when it has
  99.   received a message. It will collect the message, read and
  100.   alter it before it replies and the program terminates.
  101.  
  102.   B: This program will create a message of type NrMessage. It
  103.   will then try to find a message port called "NrPort". If it
  104.   finds that port it will send a message to it, and wait for
  105.   the other task to reply.
  106.  
  107.   Start program A then program B.
  108.  
  109.  
  110. Example 2
  111.   This program will open the Timer Device to which we  connect
  112.   a message port. When the Timer Device has done our request
  113.   (waiting for 10 seconds) it will send a message to the
  114.   message port which tells us that the time has passed.
  115.  
  116.   This example demonstrates how you can give the system (like
  117.   the Timer Device) a message port through which the system can
  118.   communicate with us. Although we are using the Timer Device,
  119.   it is only as a demonstration on how to work with message
  120.   ports. For more information about the Timer Device, see
  121.   chapter Timer Device.
  122.  
  123.  
  124. Example 3
  125.   This program will open two ports. The first port is used by
  126.     the Timer Device while the second port will not be used at
  127.     all (it is a dummy port). The reason why this example opens
  128.     an extra port is because I want to demonstrate how you can
  129.     handle two message ports simultaniously. With this technique
  130.     you can monitor up to 32 ports (the system usually needs some
  131.     singnals, but you have at least 16 signals for yourself).
  132.  
  133.  
  134.  
  135. 4.5  DIRTY INPUT
  136.  
  137. Joystick
  138.   Joystick() is a handy, easy and fast but naughty function
  139.   that hits the hardware of the Amiga. It looks at either port
  140.   1 or port 2, and returns a bitfield containing the position
  141.   of the stick and the present state of the button.
  142.  
  143. Mouse
  144.   Mouse() is a handy, easy and fast but naughty function that
  145.   hits the hardware of the Amiga. It looks at either port 1 or
  146.   port 2, and returns the (x and y) delta movement of the
  147.   mouse, as well as a bitfield containing the present state of
  148.   the three buttons. (A normal Amiga mouse has only two buttons
  149.   (left and right), but it is possible to connect a mouse with
  150.   three buttons, so why shouldn't we support it?)
  151.  
  152. Keyboard
  153.   Keyboard() is a handy, easy and fast but naughty function
  154.   that hits the hardware of the Amiga. It checks the keyboard,
  155.   and returns the Raw Key Code. (See appendix "SYSTEM DEFAULT
  156.   CONSOLE KEY MAPPING" for the full list of Raw Key Codes.)
  157.  
  158. Analogue
  159.   This is an Analogue Joystick reader. It is handy, easy and
  160.   fast but a bit naughty function since it reads directly from
  161.   the hardware registers. It can read either port 1 ("the mouse
  162.   port") or port 2 ("the joystick port"). Note that an Analogue
  163.   Joystick can have two buttons.
  164.  
  165.