home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / UTIL / DEF / PPMISC.DEF < prev   
Text File  |  1996-08-03  |  5KB  |  126 lines

  1. DEFINITION MODULE PPMisc;
  2.  
  3.         (********************************************************)
  4.         (*                                                      *)
  5.         (*      Miscellaneous procedures for preprocessor.      *)
  6.         (*                                                      *)
  7.         (*      The purpose of this module is to collect        *)
  8.         (*      together the compiler-dependent of the          *)
  9.         (*      preprocessor.  The module consists mostly       *)
  10.         (*      of file and string operations.                  *)
  11.         (*                                                      *)
  12.         (*  Programmer:         P. Moylan                       *)
  13.         (*  Last edited:        3 August 1996                   *)
  14.         (*  Status:             Working with FST, TopSpeed 1.17 *)
  15.         (*                        TopSpeed 3.10, and XDS        *)
  16.         (*                                                      *)
  17.         (*  Rowley version is untested and probably wrong.      *)
  18.         (*                                                      *)
  19.         (********************************************************)
  20.  
  21. (*<FST|Rowley
  22. IMPORT FileSystem;
  23. >*)
  24.  
  25. (*<TopSpeed
  26. IMPORT FIO;
  27. >*)
  28.  
  29. (*<XDS*)
  30. IMPORT IOChan;
  31. (*>*)
  32.  
  33. TYPE File = (*<TopSpeed FIO.File; >*)
  34.             (*<FST|Rowley FileSystem.File; >*)
  35.             (*<XDS*) IOChan.ChanId; (*>*)
  36.  
  37. (************************************************************************)
  38. (*                         STRING OPERATIONS                            *)
  39. (************************************************************************)
  40.  
  41. PROCEDURE Length (s: ARRAY OF CHAR): CARDINAL;
  42.  
  43.     (* Returns the length of string s. *)
  44.  
  45. PROCEDURE StringMatch (s1, s2: ARRAY OF CHAR): BOOLEAN;
  46.  
  47.     (* Returns TRUE iff the two strings are equal. *)
  48.  
  49. PROCEDURE CopyString (src: ARRAY OF CHAR;  VAR (*OUT*) dst: ARRAY OF CHAR);
  50.  
  51.     (* Copies src to dst. *)
  52.  
  53. PROCEDURE Pos (pattern, string: ARRAY OF CHAR): CARDINAL;
  54.  
  55.     (* If pattern is a substring of string, returns the index in        *)
  56.     (* string of the start of the first occurrence of pattern.  If      *)
  57.     (* no match then the value returned is beyond the end of string.    *)
  58.  
  59. (************************************************************************)
  60. (*                              TERMINAL I/O                            *)
  61. (************************************************************************)
  62.  
  63. PROCEDURE Message (mess: ARRAY OF CHAR);
  64.  
  65.     (* Writes a string to the screen. *)
  66.  
  67. PROCEDURE EndOfMessage;
  68.  
  69.     (* Goes to the next line on the screen. *)
  70.  
  71. PROCEDURE CommandLine (argNr: CARDINAL;  VAR (*OUT*) strg : ARRAY OF CHAR;
  72.                                         VAR (*OUT*) arglen : CARDINAL);
  73.  
  74.     (* Picks up argument number argNr from the command line.  If there  *)
  75.     (* is no such argument then arglen is returned as zero.             *)
  76.  
  77.     (* Warning: in the XDS case, argNr is ignored and arguments are     *)
  78.     (* processed strictly in their order of occurrence.                 *)
  79.  
  80. (************************************************************************)
  81. (*                           FILE OPERATIONS                            *)
  82. (************************************************************************)
  83.  
  84. PROCEDURE OpenFile (VAR (*OUT*) f: File;  filename: ARRAY OF CHAR;
  85.                                                 create: BOOLEAN): BOOLEAN;
  86.  
  87.     (* Opens the file specified as "filename".  We open it for input if *)
  88.     (* create=FALSE, or create a new file for output if create=TRUE.    *)
  89.     (* The function result indicates success.                           *)
  90.  
  91.     (* Warning: the code used for TopSpeed allocates file buffers on    *)
  92.     (* the assumption that we never have more than one input file and   *)
  93.     (* one output file open at any one time.                            *)
  94.  
  95. PROCEDURE CloseFile (VAR (*INOUT*) f: File);
  96.  
  97.     (* Closes file f. *)
  98.  
  99. PROCEDURE EndOfFile (VAR (*INOUT*) f: File): BOOLEAN;
  100.  
  101.     (* Returns TRUE iff the end of file f has been reached. *)
  102.  
  103. PROCEDURE WriteToFile (VAR (*INOUT*) f: File;
  104.                                 VAR (*IN*) str: ARRAY OF CHAR);
  105.  
  106.     (* Writes a text string to file f. *)
  107.  
  108. PROCEDURE TerminateLine (VAR (*INOUT*) f: File);
  109.  
  110.     (* Writes an end-of-line to file f. *)
  111.  
  112. PROCEDURE ReadLine (VAR (*INOUT*) f: File;  VAR (*OUT*) strg: ARRAY OF CHAR);
  113.  
  114.     (* Reads a line of text from file f. *)
  115.  
  116. PROCEDURE DeleteFile (name: ARRAY OF CHAR);
  117.  
  118.     (* Deletes a file, if it exists.  The file must not be open. *)
  119.  
  120. PROCEDURE RenameFile (originalname, newname: ARRAY OF CHAR);
  121.  
  122.     (* Renames an existing file.  The file should not be open. *)
  123.  
  124. END PPMisc.
  125.  
  126.