PROGARGS.DEF 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. (* ========================================================= *)
  2. (* Preliminary library module for Gardens Point Modula *)
  3. (* ========================================================= *)
  4. (* !SYSTEM! *) DEFINITION MODULE ProgArgs;
  5. (* this is a system module; it is known to the compiler and *)
  6. (* activated by import. There is no explicit implementation. *)
  7. PROCEDURE ArgNumber() : CARDINAL;
  8. (* postcondition : returns number of arguments with UNIX *)
  9. (* conventions. Returns 1 if no args given *)
  10. PROCEDURE GetArg(num : CARDINAL; VAR arg : ARRAY OF CHAR);
  11. (* precondition : 0 <= num <= ArgNumber() - 1 *)
  12. (* postcondition : arg is a nul terminated string. ( ==> *)
  13. (* it is fast even if HIGH(arg) >> length) *)
  14. (* usage example: to simply print all the arguments --
  15. FOR ix := 0 TO ArgNumber() - 1 DO
  16. GetArg(ix,str); WriteString(str); WriteLn;
  17. END;
  18. *)
  19. PROCEDURE EnvironString(inStr : ARRAY OF CHAR;
  20. VAR outStr : ARRAY OF CHAR);
  21. (* precondition : HIGH(outStr) must be > than length of *)
  22. (* outString ... no checking is done. *)
  23. (* postcondition : outStr holds value of environ variable, *)
  24. (* or an empty string if inStr not defined *)
  25. PROCEDURE VersionTime(VAR outStr : ARRAY OF CHAR);
  26. (* precondition : HIGH(outStr) > 26 *)
  27. (* postcondition : outStr is a nul terminated string with *)
  28. (* the date and time at which the program *)
  29. (* was built. The string includes newline *)
  30. (* usage example: to print version time --
  31. WriteString("Program version of ");
  32. VersionTime(str);
  33. WriteString(str); (* no WriteLn needed *)
  34. *)
  35. PROCEDURE UNIXtime() : CARDINAL;
  36. (* returns time in seconds since 00:00:00, GMT Jan 1 1970 *)
  37. PROCEDURE UNIXexit(res : CARDINAL);
  38. (* exits program returning result code res to UNIX caller *)
  39. PROCEDURE Assert(expr : BOOLEAN);
  40. optString : ARRAY OF CHAR);
  41. (* If expr is FALSE, the program aborts with the message *)
  42. (* optString. The open array is optional, and if used *)
  43. (* replaces the module name message which is otherwise *)
  44. (* generated *)
  45. (* From the command line "gpm -a" suppresses assert tests *)
  46. END ProgArgs.