IMPLEMENTATION MODULE PPMisc; (********************************************************) (* *) (* Miscellaneous procedures for preprocessor. *) (* *) (* The purpose of this module is to collect *) (* together the compiler-dependent of the *) (* preprocessor. The module consists mostly *) (* of file and string operations. *) (* *) (* Programmer: P. Moylan *) (* Last edited: 15 March 1994 *) (* Status: Working with FST, TopSpeed 1.17 *) (* and TopSpeed 3.10 *) (* *) (* Rowley version is untested and probably wrong. *) (* *) (********************************************************) (**) (**) (**) (************************************************************************) (**) (************************************************************************) (* STRING OPERATIONS *) (************************************************************************) PROCEDURE Length (s: ARRAY OF CHAR): CARDINAL; (* Returns the length of string s. *) BEGIN RETURN (**) (**) END Length; (************************************************************************) PROCEDURE StringMatch (s1, s2: ARRAY OF CHAR): BOOLEAN; (* Returns TRUE iff the two strings are equal. *) BEGIN (**) (**) (**) END StringMatch; (************************************************************************) PROCEDURE CopyString (src: ARRAY OF CHAR; VAR (*OUT*) dst: ARRAY OF CHAR); (* Copies src to dst. *) BEGIN (**) (**) END CopyString; (************************************************************************) PROCEDURE Pos (pattern, string: ARRAY OF CHAR): CARDINAL; (* If pattern is a substring of string, returns the index in *) (* string of the start of the first occurrence of pattern. If *) (* no match then the value returned is beyond the end of string. *) BEGIN (**) (**) END Pos; (************************************************************************) (* TERMINAL I/O *) (************************************************************************) PROCEDURE Message (mess: ARRAY OF CHAR); (* Writes a string to the screen. *) BEGIN (**) (**) END Message; (************************************************************************) PROCEDURE EndOfMessage; (* Goes to the next line on the screen. *) BEGIN (**) (**) END EndOfMessage; (************************************************************************) PROCEDURE CommandLine (argNr: CARDINAL; VAR (*OUT*) strg : ARRAY OF CHAR; VAR (*OUT*) arglen : CARDINAL); (* Picks up argument number argNr from the command line. *) (**) (**) (**) (************************************************************************) (* FILE OPERATIONS *) (************************************************************************) PROCEDURE OpenFile (VAR (*OUT*) f: File; filename: ARRAY OF CHAR; create: BOOLEAN): BOOLEAN; (* Opens the file specified as "filename". We open it for input if *) (* create=FALSE, or create a new file for output if create=TRUE. *) (* The function result indicates success. *) (**) BEGIN (**) (**) END OpenFile; (************************************************************************) PROCEDURE CloseFile (VAR (*INOUT*) f: File); (* Closes file f. *) BEGIN (**) (**) END CloseFile; (************************************************************************) PROCEDURE EndOfFile (VAR (*INOUT*) f: File): BOOLEAN; (* Returns TRUE iff the end of file f has been reached. *) (* Remark: in the TopSpeed case the library procedure FIO.EOF is *) (* inadequate for this purpose, because (a) it is only updated *) (* after a read, and (b) there is no feedback about WHICH file has *) (* reached its end. *) BEGIN (**) (*= FIO.Size(f); (*>*) END EndOfFile; (************************************************************************) PROCEDURE WriteToFile (VAR (*INOUT*) f: File; VAR (*IN*) str: ARRAY OF CHAR); (* Writes a text string to file f. *) BEGIN (**) (**) (**) END WriteToFile; (************************************************************************) PROCEDURE TerminateLine (VAR (*INOUT*) f: File); (* Writes an end-of-line to file f. *) BEGIN (**) (**) (**) END TerminateLine; (************************************************************************) PROCEDURE ReadLine (VAR (*INOUT*) f: File; VAR (*OUT*) strg: ARRAY OF CHAR); (* Reads a line of text from file f. *) BEGIN (**) (**) (**) END ReadLine; (************************************************************************) PROCEDURE DeleteFile (name: ARRAY OF CHAR); (* Deletes a file, if it exists. The file must not be open. *) BEGIN (**) (**) END DeleteFile; (************************************************************************) PROCEDURE RenameFile (originalname, newname: ARRAY OF CHAR); (* Renames an existing file. The file should not be open. *) BEGIN (**) (**) END RenameFile; (************************************************************************) END PPMisc.