home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / utilities / countervar_1 < prev    next >
Text File  |  1999-04-27  |  2KB  |  63 lines

  1. Title:            COUNTERVAR
  2. Author:            Nicholas Clark <bagpuss.done.net>
  3. Version:        0.02
  4. Title From:        Documentation
  5. Author From:        Documentation
  6. Version From:        Documentation
  7. Supplier:        Nicholas Clark <bagpuss.done.net>
  8. Date:            05/03/97
  9. Keywords:        Utility programs
  10. Shareware:        No
  11. Machine:        Archimedes
  12. Operating system:    RISCOS
  13. Memory requirements:    
  14. Peripherals needed:    
  15. Other s/ware needed:    
  16. Directory:        micros/arch/riscos/e194
  17. Date mounted/updated:    15/03/97
  18. File names:        countervar.zip
  19. Unarchived files:    4
  20. Unarchived size:    6 kbytes
  21. Omissions:        
  22. See also:        SETTIMER (e050)
  23.  
  24. -------------------------------------------------------------------------------
  25.  
  26. Acquiring the package:
  27.  
  28. Download the archive file(s) and extract using SparkPlug 2
  29. (see the "tools_help" file in micros/arch/riscos/tools for further info).
  30.  
  31.  
  32. Description:
  33.  
  34. CounterVar is a short (140 bytes) utility to create an OS variable which acts as
  35. a counter. Every time this variable is read, its value is automatically
  36. incremented. It is designed to be replace parts of code that currently read,
  37. increment and write a conventional environment variable (eg the UnixLib pipe
  38. counter)
  39.  
  40. The utility is able to create any number of counter variables - call it once for
  41. each counter to create. The name of the variable to create is supplied as the
  42. first parameter, the optional second parameter is the initial value (defaults to
  43. zero)
  44.  
  45. CounterHex counts in hexadecimal rather than decimal (and always generates
  46. exactly 8 character output.)
  47.  
  48. The counter variable is implemented as a code variable - the advantages of this
  49. method over reading, modifying and writing a conventional variable from inside
  50. your code are:
  51.  
  52. 0: The code variable method is almost certainly more compact.
  53. 1: This method will be faster - only one SWI call to read the variable, none to
  54.    write it back
  55. 2: [As long as you aren't trying to read the counter under interrupts] you can't
  56.    accidentally read the same value twice.
  57.    Using a conventional variable, two programs running in task windows can, if
  58.    one is unlucky enough to read the value just after a second program has read
  59.    it, but just before the second program writes back the incremented value.
  60.  
  61. Hopefully the source serves as an example of how to write a transient utility,
  62. and how to write a code variable.
  63.