home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / modu1096.zip / GPMsym / progargs.def < prev    next >
Text File  |  1996-08-29  |  4KB  |  84 lines

  1. (****************************************************************)
  2. (*                                                              *)
  3. (*         Gardens Point Modula-2 Library Definition            *)
  4. (*                                                              *)
  5. (*                                                              *)
  6. (*     (c) Copyright 1996 Faculty of Information Technology     *)
  7. (*              Queensland University of Technology             *)
  8. (*                                                              *)
  9. (*     Permission is granted to use, copy and change this       *)
  10. (*     program as long as the copyright message is left intact  *)
  11. (*                                                              *)
  12. (****************************************************************)
  13.  
  14. (* !SYSTEM! *) DEFINITION MODULE ProgArgs;
  15.  
  16. (* this is a system module; it is known to the compiler and  *)
  17. (* activated by import. There is no explicit implementation. *)
  18.  
  19.   PROCEDURE ArgNumber() : CARDINAL;
  20.   (* postcondition : returns number of arguments with UNIX   *)
  21.   (*                 conventions. Returns 1 if no args given *)
  22.  
  23.   PROCEDURE GetArg(num : CARDINAL; VAR arg : ARRAY OF CHAR);
  24.   (* precondition  : 0 <= num <= ArgNumber() - 1             *)
  25.   (* postcondition : arg is a nul terminated string. ( ==>   *)
  26.   (*                 it is fast even if HIGH(arg) >> length) *)
  27.  
  28.   (* usage example: to simply print all the arguments --
  29.  
  30.        FOR ix := 0 TO ArgNumber() - 1 DO
  31.          GetArg(ix,str); WriteString(str); WriteLn;
  32.        END;
  33.   *)
  34.  
  35.   PROCEDURE EnvironString(inStr  : ARRAY OF CHAR;
  36.                       VAR outStr : ARRAY OF CHAR);
  37.   (* precondition  : HIGH(outStr) must be > than length of   *)
  38.   (*                 outString ... no checking is done.      *)
  39.   (* postcondition : outStr holds value of environ variable, *)
  40.   (*                 or an empty string if inStr not defined *)
  41.  
  42.   PROCEDURE VersionTime(VAR outStr : ARRAY OF CHAR);
  43.   (* precondition  : HIGH(outStr) > 26                       *)
  44.   (* postcondition : outStr is a nul terminated string with  *)
  45.   (*                 the date and time at which the program  *)
  46.   (*                 was built. The string includes newline  *)
  47.  
  48.   (* usage example: to print version time --
  49.    *
  50.    *   WriteString("Program version of ");
  51.    *   VersionTime(str);
  52.    *   WriteString(str); (* no WriteLn needed *)
  53.    *)
  54.  
  55.   PROCEDURE UNIXtime() : CARDINAL;
  56.   (* returns time in seconds since 00:00:00, GMT Jan 1 1970 *)
  57.  
  58.   PROCEDURE UNIXexit(res : CARDINAL);
  59.   (* exits program returning result code res to UNIX caller *)
  60.  
  61.   PROCEDURE Assert(expr : BOOLEAN;
  62.            optString : ARRAY OF CHAR);
  63.   (* If expr is FALSE, the program aborts with the message  *)
  64.   (* optString.  The open array is optional, and if used    *)
  65.   (* replaces the module name message which is otherwise    *)
  66.   (* generated                                              *)
  67.   (* From the command line "gpm -a" suppresses assert tests *)
  68.  
  69.   VAR FP_Overflow : BOOLEAN;
  70.   (*
  71.    * This flag is set by the appropriate signal handler and remains
  72.    * set unless explicitly cleared by the application.
  73.    * The gpm front-end uses it to handle infinity on Alpha's
  74.    * (On most machines the result of an FP overflow is +infinity
  75.    *  On ALPHA it's UNPREDICTABLE.)
  76.    * Typical usage:-
  77.    *        FP_Overflow := FALSE;
  78.    *         ... some floating-point calculations
  79.    *        IF (FP_Overflow) THEN
  80.    *         ... floating-point overflow occurred
  81.    *        END;
  82.    *)
  83. END ProgArgs.
  84.