home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OL.LZH / PROCS.LZH / USAGE.ICN < prev    next >
Text File  |  1991-09-05  |  2KB  |  65 lines

  1. ############################################################################
  2. #
  3. #    Name:    usage.icn
  4. #
  5. #    Title:    Service procedures
  6. #
  7. #    Author:    Ralph E. Griswold
  8. #
  9. #    Date:    July 19, 1991
  10. #
  11. ############################################################################
  12. #
  13. #     These procedures provide various common services:
  14. #
  15. #     Usage(s)          stops executions with a message concerning the
  16. #                       expected form of usage of a program.
  17. #
  18. #     Error(L[])    writes arguments to &errout and returns.
  19. #
  20. #
  21. #     ErrorCheck(l,f)    reports an error that has been converted to
  22. #                       failure.
  23. #
  24. #     Feature(s)        succeeds if feature s is available in the running
  25. #                       implementation of Icon.
  26. #
  27. #     Requires(s)    terminates execution is feature s is not available.
  28. #
  29. #     Signature()    writes the version, host, and features support in
  30. #                       the running implementation of Icon.
  31. #
  32. ############################################################################
  33.  
  34. procedure Usage(s)
  35.    stop("Usage: ",s)
  36. end
  37.  
  38. procedure Error(L[])
  39.    push(L,"*** ")
  40.    push(L, &errout)
  41.    write ! L
  42. end
  43.  
  44. procedure ErrorCheck(line,file)
  45.    if &errortext == "" then fail    # No converted error
  46.    write("\nError ",&errornumber," at line ",line, " in file ",file)
  47.    write(&errortext)
  48.    write("offending value: ",image(&errorvalue))
  49.    return
  50. end
  51.  
  52. procedure Feature(s)
  53.    if s == &features then return else fail
  54. end
  55.  
  56. procedure Requires(s)
  57.    if not(Feature(s)) then stop(s," required")
  58. end
  59.  
  60. procedure Signature()
  61.    write(&version)
  62.    write(&host)
  63.    every write(&features)
  64. end
  65.