The ModulaTor logo 7KB

The ModulaTor

Oberon-2 and Modula-2 Technical Publication

Erlangen's First Independent Modula_2 Journal! Nr. 8/Sep-1992


The ISO Modula-2 Standard Library for Oberon-2:

Definition of Interface Modules & Examples

by Elmar Baumgart, ModulaWare.

2nd ed. 31-Aug-1992, 3rd ed. 05-Mar-1993, 4th ed. 10-Nov-1994

This is a collection of definition modules of the ISO Modula-2 (M2) Standard Library which are part of ModulaWare's Oberon-2 (O2) compiler for DEC OpenVMS AlphaAXP and VAX (A2O and H2O), The interface modules comprise pseudo interface modules for ModulaWare's M2 implementation of the ISO M2 Std Lib. Their sole purpose is to be able to produce the corresponding O2 symbol files.

All descriptive comments from the M2 definition modules were omitted, because the library definitions are the same as in defined ISO M2 Standard Library. Those trying to figure out how to use the library for application program development, should read the description contained in the M2 definition modules in The ModulaTor, Vol 1, Nr 8/Sep-91/6th edition, available as file mdlt14.txt (or mdlt14ps.gz in PostScript format) from the Web. See ModulaWare's URL in the impressum below.

For a more detailed description of the ISO M2 library modules, I'd recommend to get a copy of the International Standard of SC22.WG13 ISO 10154 (Modula-2) from your national standardisation body (e.g. IEC, ANSI, BSI, DIN). But be warned, this document has more than 700 pages.

To support the additional AXP floating point data types in O2, the same extended library modules set is provided as with the M2 distribution kit. The interfaces of ModulaWare's extended ISO M2 library module are not listed in this article. The modules that support the additional AXP data floating point types S_, T_, and G_FLOATING are called RealSMath, LongTMath, and LongGMath. For the complex types S_, T_, and G_COMPLEX they are called ComplexSMath, LongComplexTMath, and LongComplexGMath. There are some [compatible] deviations in the library definition used for O2. These are mainly due to language differences between M2/O2.

  1. There is no pervasive complex type in O2. The modules ComplexMath and LongComplexMath use SYSTEM.F_COMPLEX and SYSTEM.D_COMPLEX.

  2. The recursive procedure type definition for ConvTypes.ScanState uses CTR.WORD instead of ScanType in the last parameter. (O2 doesn't allow recursive types as compared to ISO M2.)

  3. The type RndFile.FilePos is declared as CTR.QUADWORD (64 bits) instead of ARRAY implementation_defined_value OF SYSTEM.LOC in ISO M2. (The ETH O2 language specificatyion doesn't allow functions with structured return values.)

  4. Procedure RawIO.Write is defined in ISO M2 as

    PROCEDURE Write (c: IOChan.ChanId; from: ARRAY OF SYSTEM.LOC)

    In O2 the corresponding definition is

    PROCEDURE Write* (c: IOChan.ChanId; VAR from: ARRAY OF SYSTEM.BYTE)

    because only variable open array parameters of type SYSTEM.BYTE are compatible with any type in O2 (see O2 Report by M~ossenb~ock/Wirth, Appendix C: The module SYSTEM).

    Due to compatible parameter passing mechanisms for value and variable parameters in OpenVMS AXP|VAX, this doesn't require any alternate implementation module for O2 (the called procedure is responsible for making a local stack copy for value parameters). The only restriction is, that O2 doesn't allow the substitution of a [constant] expression for the from parameter in RawIO.Write, e.g. RawIO.Write(c, 1) isn't allowed. In this case an auxiliary procedure has to be declared or a temporary variable has to be used, e.g. VAR t: SHORTINT; ... t:=1; RawIO.Write(c, t) ... This by the way shows, that there are generic whole number constants for the different whole number types (SHORTINT, INTEGER, LONGINT) in O2. But what is the size of those constants? How many bytes should RawIO.Write(c, 1) take? The use of a temporary variable for that purpose avoids the implicit size problem with whole number literals.

  5. O2's type definitions for ISO M2's unsigned, signed and address date types are CARDINAL = LONGINT; INTEGER = LONGINT; ADDRESS = LONGINT. These are exported from the central type definition-only module CTR, shown below. (There is no unsigned whole number type in O2.) LONGINT was used for ISO M2's type ADDRESS, because O2's pervasive function procedure SYSTEM.ADR is of type LONGINT and not SYSTEM.PTR, as would be more logical to me. Anyway, each of the to types has advantages as well as disatvantages. (Variables of any pointer type can be assigned to variables of type SYSTEM.PTR but not vice versa in O2, as it would be needed for the return value of Processes.MyParam(), to avoid a type cast using SYSTEM.VAL.)

  6. In O2 there is no type safety guaranteed when using the various enumeration types of the ISO M2 Std Lib. All those enumeration types are of type CTR.ENUM8 which is a synonym for O2's SHORTINT (8 bit) and are thus compatible with SHORTINT and all enumeration types are compatible amongst each other. (There are no enumeration types in O2, the only features that I'm sometimes missing. But may be we get statement sequences as block objects instead in O2 soon <g>; see the new article of M~ossenb~ock in ACM SigPlan, Vol 27, Nr 8, Aug-92, pp 83..86)

    The so-called simple I/O modules with the prefix "S" and "IO" suffix (SRawIO, STextIO, SRealIO, SLongIO, SWholeIO, and SIOResult) were omitted from the list below, because their definition is identical to the corresponding modules without the prefix "S", except that always the parameter cid of type ChanId is missing (i.e. implicit parameter, see module StdChans). For example,

    module SRealIO defines

    PROCEDURE WriteFloat* (real: REAL; sigFigs: CTR.CARDINAL; width: CTR.CARDINAL);

    whereas module SRealIO defines

    PROCEDURE WriteFloat* (cid: IOChan.ChanId; real: REAL; sigFigs: CTR.CARDINAL; width: CTR.CARDINAL);

  7. Procedure SysClock.GetClock is the only procedure in the ISO M2 Library that has a variable parameter of record type (VarParRecord). In this case, the records type-descriptor is passed in addition to the record's address in O2. In H2O, the M2 implementation module of SysClock, procedure GetClock detects whether it is called by M2 or O2 by checking the number of parameters on the argument stack. On AXP, both MaX and A2O pass type descriptors in case of VarParRecord. In M2, this is value is a dummy and is ignored.
Warning: No warranty for correctness of the transformation from the ISO M2 Standard Library definition modules to the set of O2 interface modules can be given. No guarantee can be given that this set exactly matches those of ISO M2.

Examples:

Two examples show how to copy a text file from an input to an output channel (example 1: module TestCopy) and how to write, rewrite and read sequential files (example 2: module TestSeqo):

E1. Module TestCopy takes its file name parameters in and out from command line (argument channel) using module ProgramArgs and copies the text file using TextIO.

E2. Module TestSeqo uses module SeqFile for the file read and [re-]write operations. It calculates and displays some performance data for the ISO M2 Std I/O-Lib.

Yet another example called UseProcesses is contained in The ModulaTor, Vol 2, Nr. 7, Aug-92 (file mdlt25.txt and mdlt25ps.gz). UseProcesses is an O2 multi-programming example and uses ISO M2 Std Lib's modules Processes and Sempahores.


___________________________________________________________________

MODULE CTR;
(* central definition of INTEGER and CARDINAL *)
IMPORT SYSTEM;

TYPE 
  INTEGER* = LONGINT; (* 32 Bit signed whole number type *)
  CARDINAL* = LONGINT;
  ADDRESS* = LONGINT; (* SYSTEM.ADR() is of LONGINT type! *)

(* select your enumeration types carefully: *)
  ENUM8* = SHORTINT; (* ORD(MAX(corresponding_Modula_2_enum) < 256 *)
  ENUM16* = INTEGER; (* ORD(MAX(corresponding_Modula_2_enum) < 65536 *)
  ENUM32* = LONGINT; (* ORD(MAX(corresponding_Modula_2_enum) < 2^31 :-) *)

(* WORD and QUADWORD are extension of the Oberon-2 module SYSTEM.
   Sorry, there was no other way! *)

  WORD* = SYSTEM.WORD; (* 32 Bit *)
  (* WORD is used in ConvType only (no recursive procedure definitions) *)

  QUADWORD* = SYSTEM.QUADWORD; (* 64 Bit *)
  (* QUADWORD is used in RndFile only (no structured function values) *)

END CTR.

___________________________________________________________________

MODULE IOConsts;
IMPORT CTR;

TYPE
  ReadResults* = CTR.ENUM8;

CONST
  notKnown*   = 0;
  allRight*   = 1;
  outOfRange* = 2;
  wrongFormat*= 3;
  endOfLine*  = 4;
  endOfInput* = 5;

END IOConsts.

___________________________________________________________________

MODULE ChanConsts;
IMPORT CTR;

TYPE 
  INTEGER = CTR.INTEGER;
  CARDINAL = CTR.CARDINAL;

TYPE
  ChanFlags* = CTR.ENUM8;

CONST
    readFlag* =        0;
    writeFlag* =       1;
    oldFlag* =         2;
    textFlag* =        3;
    rawFlag* =         4;
    interactiveFlag* = 5;
    echoFlag* =        6;

TYPE
  FlagSet* = SET;

CONST
  read* =        {readFlag};
  write* =       {writeFlag};
  old* =         {oldFlag};
  text* =        {textFlag};
  raw* =         {rawFlag};
  interactive* = {interactiveFlag};
  echo* =        {echoFlag};

TYPE
  OpenResults* = CTR.ENUM8;

CONST
  opened            * = 0;
  wrongNameFormat   * = 1;
  wrongFlags        * = 2;
  tooManyOpen       * = 3;
  outOfChans        * = 4;
  wrongPermissions  * = 5;
  noRoomOnDevice    * = 6;
  noSuchFile        * = 7;
  fileExists        * = 8;
  wrongFileType     * = 9;
  noTextOperations  * = 10;
  noRawOperations   * = 11;
  noMixedOperations * = 12;
  alreadyOpen       * = 13;
  otherProblem      * = 14;

END ChanConsts.

___________________________________________________________________

MODULE IOChan;
IMPORT SYSTEM, CTR, IOConsts, ChanConsts;

TYPE
  ChanExceptions* = CTR.ENUM8;
CONST
  wrongDevice* = 1;
  notAvailable* = 2;
  skipAtEnd* = 3;
  softDeviceError* = 4;
  hardDeviceError* = 5;
  textParseError* = 6;
  notAChannel* = 7;

TYPE 
  ChanId* = POINTER TO RECORD END;

TYPE
  DeviceErrNum* = CTR.INTEGER;

PROCEDURE Look* (cid: ChanId; VAR ch: CHAR; VAR res: IOConsts.ReadResults);
 END Look;

PROCEDURE Skip* (cid: ChanId);
 END Skip;

PROCEDURE SkipLook* (cid: ChanId; VAR ch: CHAR; VAR res: IOConsts.ReadResults);
 END SkipLook;

PROCEDURE TextRead* (cid: ChanId; to: CTR.ADDRESS; maxChars: CTR.CARDINAL;
                    VAR charsRead: CTR.CARDINAL);
 END TextRead;

PROCEDURE TextWrite* (cid: ChanId; from: CTR.ADDRESS; 
                      charsToWrite: CTR.CARDINAL);
 END TextWrite;

PROCEDURE WriteLn* (cid: ChanId);
 END WriteLn;

PROCEDURE RawRead* (cid: ChanId; to: CTR.ADDRESS; maxLocs: CTR.CARDINAL;
                   VAR locsRead: CTR.CARDINAL);
 END RawRead;

PROCEDURE RawWrite* (cid: ChanId; from: CTR.ADDRESS; locsToWrite: CTR.CARDINAL);
 END RawWrite;

PROCEDURE GetName* (cid: ChanId; VAR s: ARRAY OF CHAR);
 END GetName;

PROCEDURE Reset* (cid: ChanId);
 END Reset;

PROCEDURE Flush* (cid: ChanId);
 END Flush;

PROCEDURE SetReadResult* (cid: ChanId; res: IOConsts.ReadResults);
 END SetReadResult;

PROCEDURE ReadResult* (cid: ChanId) : IOConsts.ReadResults;
 END ReadResult;

PROCEDURE CurrentFlags* (cid: ChanId) : ChanConsts.FlagSet;
 END CurrentFlags;

PROCEDURE IsChanException* () : BOOLEAN;
 END IsChanException;

PROCEDURE ChanException* () : ChanExceptions;
 END ChanException;

PROCEDURE DeviceError* (cid: ChanId) : DeviceErrNum;
 END DeviceError;

PROCEDURE InvalidChan* () : ChanId;
 END InvalidChan;

END IOChan.

___________________________________________________________________

MODULE IOLink;
IMPORT IOChan, IOConsts, ChanConsts, SYSTEM, CTR;

TYPE 
  DeviceId* =       POINTER TO DeviceIdRec;
  DeviceIdRec* =    RECORD END;

  DeviceTablePtr *= POINTER TO DeviceTable;

  LookProc *=       PROCEDURE (a: DeviceTablePtr; VAR b: CHAR;
                           VAR c: IOConsts.ReadResults);
  SkipProc *=       PROCEDURE (a: DeviceTablePtr);
  SkipLookProc *=   PROCEDURE (a: DeviceTablePtr; VAR b: CHAR;
                           VAR c: IOConsts.ReadResults);
  TextReadProc *=   PROCEDURE (a: DeviceTablePtr; b: CTR.ADDRESS; 
                               c: CTR.CARDINAL; VAR d: CTR.CARDINAL);
  TextWriteProc *=  PROCEDURE (a: DeviceTablePtr; b: CTR.ADDRESS;
                              c: CTR.CARDINAL);
  WriteLnProc *=    PROCEDURE (a: DeviceTablePtr);
  RawReadProc *=    PROCEDURE (a: DeviceTablePtr; b: CTR.ADDRESS; 
                               c: CTR.CARDINAL; VAR d: CTR.CARDINAL);
  RawWriteProc *=   PROCEDURE (a: DeviceTablePtr; b: CTR.ADDRESS;
                               c: CTR.CARDINAL);
  GetNameProc *=    PROCEDURE (a: DeviceTablePtr; VAR b: ARRAY OF CHAR);
  ResetProc *=      PROCEDURE (a: DeviceTablePtr);
  FlushProc *=      PROCEDURE (a: DeviceTablePtr);
  FreeProc *=       PROCEDURE (a: DeviceTablePtr);

  DeviceData *=     CTR.ADDRESS;

  DeviceTable *=
    RECORD
      cd*:               DeviceData;              
      did*:              DeviceId;               
      cid*:       IOChan.ChanId;          
      result*:  IOConsts.ReadResults; 
      errNum*:    IOChan.DeviceErrNum; 
      flags*: ChanConsts.FlagSet;   
      doLook*:           LookProc;            
      doSkip*:           SkipProc;            
      doSkipLook*:       SkipLookProc;    
      doLnWrite*:        WriteLnProc;      
      doTextRead*:       TextReadProc;    
      doTextWrite*:      TextWriteProc;  
      doRawRead*:        RawReadProc;      
      doRawWrite*:       RawWriteProc;    
      doGetName*:        GetNameProc;      
      doReset*:          ResetProc;          
      doFlush*:          FlushProc;          
      doFree*:           FreeProc;          
    END;

  DevExceptionRange *= CTR.ENUM8;
   (* is subrange type [IOChan.notAvailable ..  IOChan.textParseError];*)

PROCEDURE AllocateDeviceId *(VAR did: DeviceId);
END AllocateDeviceId;

PROCEDURE MakeChan *(did: DeviceId; VAR cid: IOChan.ChanId);
END MakeChan;

PROCEDURE UnMakeChan *(did: DeviceId; VAR cid: IOChan.ChanId);
END UnMakeChan;

PROCEDURE DeviceTablePtrValue *(cid: IOChan.ChanId; did: DeviceId;
                               x: DevExceptionRange; s:  ARRAY OF CHAR): DeviceTableP
tr;
END DeviceTablePtrValue;

PROCEDURE IsDevice *(cid: IOChan.ChanId; did: DeviceId) : BOOLEAN;
END IsDevice;

PROCEDURE RAISEdevException *(cid: IOChan.ChanId; did: DeviceId;
                              x: DevExceptionRange; s: ARRAY OF CHAR);
END RAISEdevException;

PROCEDURE IsIOException *() : BOOLEAN;
END IsIOException;

PROCEDURE IOException *() : IOChan.ChanExceptions;
END IOException;

END IOLink.

___________________________________________________________________

MODULE RawIO;
IMPORT IOChan, SYSTEM;

PROCEDURE Read* (cid: IOChan.ChanId; VAR to: ARRAY OF SYSTEM.BYTE);
 END Read;

PROCEDURE Write* (cid: IOChan.ChanId; 
                  VAR (*Oberon-2 compatible *) from: ARRAY OF SYSTEM.BYTE);
 END Write;

END RawIO.

___________________________________________________________________

MODULE TextIO;

IMPORT IOChan;

PROCEDURE ReadChar* (cid: IOChan.ChanId; VAR ch: CHAR);
 END ReadChar;

PROCEDURE ReadRestLine* (cid: IOChan.ChanId; VAR s: ARRAY OF CHAR);
 END ReadRestLine;

PROCEDURE ReadString* (cid: IOChan.ChanId; VAR s: ARRAY OF CHAR);
 END ReadString;

PROCEDURE ReadToken* (cid: IOChan.ChanId; VAR s: ARRAY OF CHAR);
 END ReadToken;

PROCEDURE SkipLine* (cid: IOChan.ChanId);
 END SkipLine;

PROCEDURE WriteChar* (cid: IOChan.ChanId; ch: CHAR);
 END WriteChar;

PROCEDURE WriteLn* (cid: IOChan.ChanId);
 END WriteLn;

PROCEDURE WriteString* (cid: IOChan.ChanId; s: ARRAY OF CHAR);
 END WriteString;

END TextIO.

___________________________________________________________________

MODULE RealIO;
IMPORT IOChan, CTR;

TYPE
  INTEGER = CTR.INTEGER;
  CARDINAL = CTR.CARDINAL;

PROCEDURE ReadReal* (cid: IOChan.ChanId; VAR real: REAL);
 END ReadReal;

PROCEDURE WriteFloat* (cid: IOChan.ChanId; real: REAL; sigFigs: CARDINAL;
                       width: CARDINAL);
 END WriteFloat;

PROCEDURE WriteEng* (cid: IOChan.ChanId; real: REAL; sigFigs: CARDINAL;
                     width: CARDINAL);
 END WriteEng;

PROCEDURE WriteFixed* (cid: IOChan.ChanId; real: REAL; place: INTEGER;
                       width: CARDINAL);
 END WriteFixed;

PROCEDURE WriteReal* (cid: IOChan.ChanId; real: REAL; width: CARDINAL);
 END WriteReal;

END RealIO.

___________________________________________________________________

MODULE LongIO;
IMPORT IOChan, CTR;

TYPE
  INTEGER = CTR.INTEGER;
  CARDINAL = CTR.CARDINAL;

PROCEDURE ReadReal* (cid: IOChan.ChanId; VAR real: LONGREAL);
 END ReadReal;

PROCEDURE WriteFloat* (cid: IOChan.ChanId; real: LONGREAL; sigFigs: CARDINAL;
                      width: CARDINAL);
 END WriteFloat;

PROCEDURE WriteEng* (cid: IOChan.ChanId; real: LONGREAL; sigFigs: CARDINAL;
                    width: CARDINAL);
 END WriteEng;

PROCEDURE WriteFixed* (cid: IOChan.ChanId; real: LONGREAL; place: INTEGER;
                      width: CARDINAL);
 END WriteFixed;

PROCEDURE WriteReal* (cid: IOChan.ChanId; real: LONGREAL; width: CARDINAL);
 END WriteReal;

END LongIO.

___________________________________________________________________

MODULE WholeIO;
IMPORT IOChan, CTR;

TYPE
  INTEGER = CTR.INTEGER;
  CARDINAL = CTR.CARDINAL;

PROCEDURE ReadInt* (cid: IOChan.ChanId; VAR int: INTEGER);
 END ReadInt;

PROCEDURE WriteInt* (cid: IOChan.ChanId; int: INTEGER; width: CARDINAL);
 END WriteInt;

PROCEDURE ReadCard* (cid: IOChan.ChanId; VAR card: CARDINAL);
 END ReadCard;

PROCEDURE WriteCard* (cid: IOChan.ChanId; card: CARDINAL; width: CARDINAL);
 END WriteCard;

END WholeIO.

___________________________________________________________________

MODULE IOResult;
IMPORT IOConsts, IOChan;

TYPE ReadResults* = IOConsts.ReadResults;

CONST
  notKnown*   = IOConsts.notKnown;
  allRight*   = IOConsts.allRight;
  outOfRange* = IOConsts.outOfRange;
  wrongFormat*= IOConsts.wrongFormat;
  endOfLine*  = IOConsts.endOfLine;
  endOfInput* = IOConsts.endOfInput;

PROCEDURE ReadResult*(cid: IOChan.ChanId): ReadResults;
 END ReadResult;

END IOResult.

___________________________________________________________________

MODULE TermFile;

IMPORT IOChan, ChanConsts;

TYPE
  ChanId* = IOChan.ChanId;
  FlagSet* = ChanConsts.FlagSet;
  OpenResults* = ChanConsts.OpenResults;

CONST
  read* = {ChanConsts.readFlag};
  write* = {ChanConsts.writeFlag};
  text* = {ChanConsts.textFlag};
  raw* = {ChanConsts.rawFlag};
  echo* = {ChanConsts.echoFlag};

  opened*             = ChanConsts.opened;
  wrongNameFormat*    = ChanConsts.wrongNameFormat;
  wrongFlags*         = ChanConsts.wrongFlags;
  tooManyOpen*        = ChanConsts.tooManyOpen;
  outOfChans*         = ChanConsts.outOfChans;
  wrongPermissions*   = ChanConsts.wrongPermissions;
  noRoomOnDevice*     = ChanConsts.noRoomOnDevice;
  noSuchFile*         = ChanConsts.noSuchFile;
  fileExists*         = ChanConsts.fileExists;
  wrongFileType*      = ChanConsts.wrongFileType;
  noTextOperations*   = ChanConsts.noTextOperations;
  noRawOperations*    = ChanConsts.noRawOperations;
  noMixedOperations*  = ChanConsts.noMixedOperations;
  alreadyOpen*        = ChanConsts.alreadyOpen;
  otherProblem*       = ChanConsts.otherProblem;

PROCEDURE Open* (VAR cid: ChanId; flags: FlagSet; VAR res: OpenResults);
 END Open;

PROCEDURE IsTermFile* (cid: ChanId) : BOOLEAN;
 END IsTermFile;

PROCEDURE Close* (VAR cid: ChanId);
 END Close;

END TermFile.

___________________________________________________________________

MODULE RndFile;

IMPORT IOChan, ChanConsts, CTR;

TYPE
  INTEGER = CTR.INTEGER;
  CARDINAL = CTR.CARDINAL;

TYPE
  ChanId* = IOChan.ChanId;
  FlagSet* = ChanConsts.FlagSet;
  OpenResults* = ChanConsts.OpenResults;

TYPE
  RndFileExceptions* = CTR.ENUM8;

CONST
  read* = {ChanConsts.readFlag};
  write* = {ChanConsts.writeFlag};
  old* = {ChanConsts.oldFlag};
  text* = {ChanConsts.textFlag};
  raw* = {ChanConsts.rawFlag};

  opened*             = ChanConsts.opened;
  wrongNameFormat*    = ChanConsts.wrongNameFormat;
  wrongFlags*         = ChanConsts.wrongFlags;
  tooManyOpen*        = ChanConsts.tooManyOpen;
  outOfChans*         = ChanConsts.outOfChans;
  wrongPermissions*   = ChanConsts.wrongPermissions;
  noRoomOnDevice*     = ChanConsts.noRoomOnDevice;
  noSuchFile*         = ChanConsts.noSuchFile;
  fileExists*         = ChanConsts.fileExists;
  wrongFileType*      = ChanConsts.wrongFileType;
  noTextOperations*   = ChanConsts.noTextOperations;
  noRawOperations*    = ChanConsts.noRawOperations;
  noMixedOperations*  = ChanConsts.noMixedOperations;
  alreadyOpen*        = ChanConsts.alreadyOpen;
  otherProblem*       = ChanConsts.otherProblem;

CONST
  FilePosSize* = SIZE(CTR.QUADWORD);

TYPE
  FilePos* = CTR.QUADWORD; (*ARRAY FilePosSize OF SYSTEM.BYTE;*)

PROCEDURE OpenOld* (VAR cid: ChanId; name: ARRAY OF CHAR; flags: FlagSet;
                   VAR res: OpenResults);
END OpenOld;

PROCEDURE OpenClean* (VAR cid: ChanId; name: ARRAY OF CHAR; flags: FlagSet;
                     VAR res: OpenResults);
END OpenClean;

PROCEDURE IsRndFile* (cid: ChanId) : BOOLEAN;
END IsRndFile;

PROCEDURE IsRndFileException* () : BOOLEAN;
END IsRndFileException;

PROCEDURE StartPos* (cid: ChanId) : FilePos;
END StartPos;

PROCEDURE CurrentPos* (cid: ChanId) : FilePos;
END CurrentPos;

PROCEDURE EndPos* (cid: ChanId) : FilePos;
END EndPos;

PROCEDURE NewPos* (cid: ChanId; chunks: INTEGER; chunkSize: CARDINAL;
  from: FilePos) : FilePos;
END NewPos;

PROCEDURE SetPos* (cid: ChanId; pos: FilePos);
END SetPos;

PROCEDURE Close* (VAR cid: ChanId);
END Close;

END RndFile.

___________________________________________________________________

MODULE SeqFile;
IMPORT IOChan, ChanConsts;

TYPE
  ChanId* = IOChan.ChanId;
  FlagSet* = ChanConsts.FlagSet;
  OpenResults* = ChanConsts.OpenResults;

CONST
  read* = {ChanConsts.readFlag};
  write* = {ChanConsts.writeFlag};
  old* = {ChanConsts.oldFlag};
  text* = {ChanConsts.textFlag};
  raw* = {ChanConsts.rawFlag};

  opened*             = ChanConsts.opened;
  wrongNameFormat*    = ChanConsts.wrongNameFormat;
  wrongFlags*         = ChanConsts.wrongFlags;
  tooManyOpen*        = ChanConsts.tooManyOpen;
  outOfChans*         = ChanConsts.outOfChans;
  wrongPermissions*   = ChanConsts.wrongPermissions;
  noRoomOnDevice*     = ChanConsts.noRoomOnDevice;
  noSuchFile*         = ChanConsts.noSuchFile;
  fileExists*         = ChanConsts.fileExists;
  wrongFileType*      = ChanConsts.wrongFileType;
  noTextOperations*   = ChanConsts.noTextOperations;
  noRawOperations*    = ChanConsts.noRawOperations;
  noMixedOperations*  = ChanConsts.noMixedOperations;
  alreadyOpen*        = ChanConsts.alreadyOpen;
  otherProblem*       = ChanConsts.otherProblem;

PROCEDURE OpenWrite* (VAR cid: ChanId; name: ARRAY OF CHAR; flags: FlagSet;
                     VAR res: OpenResults);
 END OpenWrite;

PROCEDURE OpenAppend* (VAR cid: ChanId; name: ARRAY OF CHAR; flags:
                      FlagSet; VAR res: OpenResults);
 END OpenAppend;

PROCEDURE OpenRead* (VAR cid: ChanId; name: ARRAY OF CHAR; flags: FlagSet;
                    VAR res: OpenResults);
 END OpenRead;

PROCEDURE IsSeqFile* (cid: ChanId) : BOOLEAN;
 END IsSeqFile;

PROCEDURE Reread* (cid: ChanId);
 END Reread;

PROCEDURE Rewrite* (cid: ChanId);
 END Rewrite;

PROCEDURE Close* (VAR cid: ChanId);
 END Close;

END SeqFile.

___________________________________________________________________

MODULE StreamFile;
IMPORT IOChan, ChanConsts;

TYPE
  ChanId* = IOChan.ChanId;
  FlagSet* = ChanConsts.FlagSet;
  OpenResults* = ChanConsts.OpenResults;

CONST
  read* = {ChanConsts.readFlag};
  write* = {ChanConsts.writeFlag};
  old* = {ChanConsts.oldFlag};
  text* = {ChanConsts.textFlag};
  raw* = {ChanConsts.rawFlag};

  opened*             = ChanConsts.opened;
  wrongNameFormat*    = ChanConsts.wrongNameFormat;
  wrongFlags*         = ChanConsts.wrongFlags;
  tooManyOpen*        = ChanConsts.tooManyOpen;
  outOfChans*         = ChanConsts.outOfChans;
  wrongPermissions*   = ChanConsts.wrongPermissions;
  noRoomOnDevice*     = ChanConsts.noRoomOnDevice;
  noSuchFile*         = ChanConsts.noSuchFile;
  fileExists*         = ChanConsts.fileExists;
  wrongFileType*      = ChanConsts.wrongFileType;
  noTextOperations*   = ChanConsts.noTextOperations;
  noRawOperations*    = ChanConsts.noRawOperations;
  noMixedOperations*  = ChanConsts.noMixedOperations;
  alreadyOpen*        = ChanConsts.alreadyOpen;
  otherProblem*       = ChanConsts.otherProblem;

PROCEDURE Open* (VAR cid: ChanId; name: ARRAY OF CHAR; flags: FlagSet;
                VAR res: OpenResults);
 END Open;

PROCEDURE IsStreamFile* (cid: ChanId) : BOOLEAN;
 END IsStreamFile;

PROCEDURE Close* (VAR cid: ChanId);
 END Close;

END StreamFile.

___________________________________________________________________

MODULE ProgramArgs;
IMPORT IOChan;

TYPE
  ChanId* = IOChan.ChanId;

PROCEDURE ArgChan* () : ChanId;
 END ArgChan;

PROCEDURE IsArgPresent* () : BOOLEAN;
 END IsArgPresent;

PROCEDURE NextArg* ();
 END NextArg;

END ProgramArgs.

___________________________________________________________________

MODULE StdChans;
IMPORT IOChan;

TYPE
  ChanId* = IOChan.ChanId;

PROCEDURE StdInChan* () : ChanId;
 END StdInChan;

PROCEDURE StdOutChan* () : ChanId;
 END StdOutChan;

PROCEDURE StdErrChan* () : ChanId;
 END StdErrChan;

PROCEDURE NullChan* () : ChanId;
 END NullChan;

PROCEDURE InChan* () : ChanId;
 END InChan;

PROCEDURE OutChan* () : ChanId;
 END OutChan;

PROCEDURE ErrChan* () : ChanId;
 END ErrChan;

PROCEDURE SetInChan* (cid: ChanId);
 END SetInChan;

PROCEDURE SetOutChan* (cid: ChanId);
 END SetOutChan;

PROCEDURE SetErrChan* (cid: ChanId);
 END SetErrChan;

END StdChans.

___________________________________________________________________

 

String Conversions Library

___________________________________________________________________

MODULE WholeConv;
IMPORT ConvTypes, CTR;

TYPE ConvResults* = ConvTypes.ConvResults; 

CONST
  strAllRight* =    ConvTypes.strAllRight;
  strOutOfRange* =  ConvTypes.strOutOfRange;  
  strWrongFormat* = ConvTypes.strWrongFormat; 
  strEmpty* =       ConvTypes.strEmpty;       

PROCEDURE ScanInt*(inputCh: CHAR; VAR chClass: ConvTypes.ScanClass; 
  VAR nextState: ConvTypes.ScanState);
END ScanInt;

PROCEDURE FormatInt*(str: ARRAY OF CHAR): ConvResults;
END FormatInt;

PROCEDURE ValueInt*(str: ARRAY OF CHAR): CTR.INTEGER;
END ValueInt;

PROCEDURE LengthInt*(int: CTR.INTEGER): CTR.CARDINAL;
END LengthInt;

PROCEDURE ScanCard*(inputCh: CHAR; VAR chClass: ConvTypes.ScanClass; 
  VAR nextState: ConvTypes.ScanState);
END ScanCard;

PROCEDURE FormatCard*(str: ARRAY OF CHAR): ConvResults;
END FormatCard;

PROCEDURE ValueCard*(str: ARRAY OF CHAR): CTR.CARDINAL;
END ValueCard;

PROCEDURE LengthCard*(card: CTR.CARDINAL): CTR.CARDINAL;
END LengthCard;

PROCEDURE IsWholeConvException* (): BOOLEAN;
END IsWholeConvException;

END WholeConv.

___________________________________________________________________

MODULE RealConv;

IMPORT
  ConvTypes, CTR;

TYPE
  ConvResults* = ConvTypes.ConvResults;

CONST
  strAllRight* =    ConvTypes.strAllRight;
  strOutOfRange* =  ConvTypes.strOutOfRange;  
  strWrongFormat* = ConvTypes.strWrongFormat; 
  strEmpty* =       ConvTypes.strEmpty;       

PROCEDURE ScanReal* (inputCh: CHAR; VAR chClass: ConvTypes.ScanClass;
  VAR nextState: ConvTypes.ScanState);
END ScanReal;

PROCEDURE FormatReal* (str: ARRAY OF CHAR): ConvResults;
END FormatReal;

PROCEDURE ValueReal* (str: ARRAY OF CHAR): REAL;
END ValueReal;

PROCEDURE LengthFloatReal* (real: REAL; sigFigs: CTR.CARDINAL): CTR.CARDINAL;
END LengthFloatReal;

PROCEDURE LengthEngReal* (real: REAL; sigFigs: CTR.CARDINAL): CTR.CARDINAL;
END LengthEngReal;

PROCEDURE LengthFixedReal* (real: REAL; place: CTR.INTEGER): CTR.CARDINAL;
END LengthFixedReal;

PROCEDURE IsRConvException* (): BOOLEAN;
END IsRConvException;

END RealConv.

___________________________________________________________________

MODULE LongConv;

IMPORT
  ConvTypes, CTR;

TYPE
  ConvResults* = ConvTypes.ConvResults;

CONST
  strAllRight* =    ConvTypes.strAllRight;
  strOutOfRange* =  ConvTypes.strOutOfRange;  
  strWrongFormat* = ConvTypes.strWrongFormat; 
  strEmpty* =       ConvTypes.strEmpty;       

PROCEDURE ScanReal* (inputCh: CHAR; VAR chClass: ConvTypes.ScanClass;
  VAR nextState: ConvTypes.ScanState);
END ScanReal;

PROCEDURE FormatReal* (str: ARRAY OF CHAR): ConvResults;
END FormatReal;

PROCEDURE ValueReal* (str: ARRAY OF CHAR): LONGREAL;
END ValueReal;

PROCEDURE LengthFloatReal* (real: LONGREAL; sigFigs: CTR.CARDINAL): CTR.CARDINAL;
END LengthFloatReal;

PROCEDURE LengthEngReal* (real: LONGREAL; sigFigs: CTR.CARDINAL): CTR.CARDINAL;
END LengthEngReal;

PROCEDURE LengthFixedReal* (real: LONGREAL; place: CTR.INTEGER): CTR.CARDINAL;
END LengthFixedReal;

PROCEDURE IsRConvException* (): BOOLEAN;
END IsRConvException;

END LongConv.

___________________________________________________________________

MODULE ConvTypes;
IMPORT CTR;

CONST
  strAllRight* = 0;
  strOutOfRange* = 1;  
  strWrongFormat* = 2; 
  strEmpty* = 3;       
  
  padding* = 0;   
  valid* = 1;     
  invalid* = 2;   
  terminator* = 3;
  
TYPE
  ConvResults* = CTR.ENUM8; 
  ScanClass* = CTR.ENUM8;   

  ScanState* =  
    PROCEDURE(ch: CHAR; VAR status: ScanClass; VAR nextStatus: CTR.WORD);
(* type of parameter nextStatus is actually ScanState, but recursive
   type definitions are not allowed in Oberon-2. *)
END ConvTypes.

___________________________________________________________________

MODULE WholeStr;
IMPORT ConvTypes, CTR;

TYPE ConvResults* = ConvTypes.ConvResults; 

CONST
  strAllRight* =    ConvTypes.strAllRight;
  strOutOfRange* =  ConvTypes.strOutOfRange;  
  strWrongFormat* = ConvTypes.strWrongFormat; 
  strEmpty* =       ConvTypes.strEmpty;       

PROCEDURE StrToInt* (str: ARRAY OF CHAR; VAR int: CTR.INTEGER; 
  VAR res: ConvResults);
END StrToInt;

PROCEDURE IntToStr* (int: CTR.INTEGER; VAR str: ARRAY OF CHAR);
END IntToStr;  

PROCEDURE StrToCard* (str: ARRAY OF CHAR; VAR card: CTR.CARDINAL; 
  VAR res: ConvResults);
END StrToCard;

PROCEDURE CardToStr* (card: CTR.CARDINAL; VAR str: ARRAY OF CHAR);
END CardToStr;  

END WholeStr.

___________________________________________________________________

MODULE RealStr;
IMPORT ConvTypes, CTR;

TYPE ConvResults* = ConvTypes.ConvResults; 

CONST
  strAllRight* =    ConvTypes.strAllRight;
  strOutOfRange* =  ConvTypes.strOutOfRange;  
  strWrongFormat* = ConvTypes.strWrongFormat; 
  strEmpty* =       ConvTypes.strEmpty;       

PROCEDURE StrToReal* (str: ARRAY OF CHAR; VAR real: REAL; 
  VAR res: ConvResults);
END StrToReal;

PROCEDURE RealToFloat* (real: REAL; sigFigs: CTR.CARDINAL; VAR str: ARRAY OF CHAR);
END RealToFloat;

PROCEDURE RealToEng* (real: REAL; sigFigs: CTR.CARDINAL; VAR str: ARRAY OF CHAR);
END RealToEng;  

PROCEDURE RealToFixed* (real: REAL; place: CTR.INTEGER; VAR str: ARRAY OF CHAR);
END RealToFixed;  

PROCEDURE RealToStr* (real: REAL; VAR str: ARRAY OF CHAR);
END RealToStr;  

END RealStr.

___________________________________________________________________

MODULE LongStr;
IMPORT ConvTypes, CTR;

TYPE ConvResults* = ConvTypes.ConvResults; 

CONST
  strAllRight* =    ConvTypes.strAllRight;
  strOutOfRange* =  ConvTypes.strOutOfRange;  
  strWrongFormat* = ConvTypes.strWrongFormat; 
  strEmpty* =       ConvTypes.strEmpty;       

PROCEDURE StrToReal* (str: ARRAY OF CHAR; VAR real: LONGREAL; 
  VAR res: ConvResults);
END StrToReal;  

PROCEDURE RealToFloat* (real: LONGREAL; sigFigs: CTR.CARDINAL; 
  VAR str: ARRAY OF CHAR);
END RealToFloat;  

PROCEDURE RealToEng* (real: LONGREAL; sigFigs: CTR.CARDINAL; 
  VAR str: ARRAY OF CHAR);
END RealToEng;  

PROCEDURE RealToFixed* (real: LONGREAL; place: CTR.INTEGER; 
  VAR str: ARRAY OF CHAR);
END RealToFixed;  

PROCEDURE RealToStr* (real: LONGREAL; VAR str: ARRAY OF CHAR);
END RealToStr;  

END LongStr.

___________________________________________________________________

MODULE CharClass;

PROCEDURE IsNumeric*(ch: CHAR): BOOLEAN;
END IsNumeric;

PROCEDURE IsLetter*(ch: CHAR): BOOLEAN;
END IsLetter;

PROCEDURE IsUpper*(ch: CHAR): BOOLEAN;
END IsUpper;

PROCEDURE IsLower*(ch: CHAR): BOOLEAN;
END IsLower;

PROCEDURE IsControl*(ch: CHAR): BOOLEAN;
END IsControl;

PROCEDURE IsWhiteSpace*(ch: CHAR): BOOLEAN;
END IsWhiteSpace;

END CharClass.
___________________________________________________________________

Example 1: How to copy a text file in O2:


___________________________________________________________________

MODULE TestCopy;
(*This Oberon-2 example shows how to copy an input text-file 
  to an output text-file (taking both file parameters from
  the command line) using the ISO-Modula-2 Std I/O-Library
  by 
  Guenter Dotzel, ModulaWare GmbH, 
  E-mail/Internet: 100023.2527@compuserve.com
*)
IMPORT ProgramArgs, IOResult, SeqFile, TextIO, ChanConsts;

TYPE fnam= ARRAY 255 OF CHAR;
VAR in,out: fnam;
  ores: ChanConsts.OpenResults;
  input, output: SeqFile.ChanId;
  line: ARRAY 8192 OF CHAR;
BEGIN
  IF ProgramArgs.IsArgPresent() THEN
    TextIO.ReadToken(ProgramArgs.ArgChan(), in);
    IF ProgramArgs.IsArgPresent() THEN
      TextIO.ReadToken(ProgramArgs.ArgChan(), out);
      SeqFile.OpenRead(input, in, SeqFile.read, ores); 
      IF ores=ChanConsts.opened THEN
        SeqFile.OpenWrite(output, out, SeqFile.write, ores);
        IF ores=ChanConsts.opened THEN
          TextIO.ReadRestLine(input, line);
          WHILE IOResult.ReadResult(input) # IOResult.endOfInput DO
            IF IOResult.ReadResult(input) = IOResult.allRight THEN 
              TextIO.WriteString(output, line); TextIO.WriteLn(output);
            ELSE TextIO.WriteLn(output);
            END;
            TextIO.SkipLine(input); TextIO.ReadRestLine(input, line);
          END;
          SeqFile.Close(input);
        END;
        SeqFile.Close(output);
      END;
    END;
  END;
END TestCopy.
___________________________________________________________________

Example 2: Sequential write & read text and binary files:

In addition to some ISO M2 Std Lib modules, module TestSeqo imports one auxiliary module TimerServices which is a combination of the OpenVMS M2 specific modules Measures and GetConvTime. Testseqo uses TimerServices.GetTimer to evaluate the elapsed time, CPU-time and other relevant information.

The listing of module TestSeqo is followed by the terminal log for compilation, linking and execution. The timings are actual values measured on a slow VAX|AXP workstations. If the performance looks poor to you, this is due to the slow machine used and is not an indicator for a poor library implementation. At least our ISO M2 Std Lib is efficiently implemented.


___________________________________________________________________

MODULE TimerServices;

IMPORT Measures, GetConvTime, CTR, SYSTEM;
TYPE
  TimeType* = SYSTEM.QUADWORD;
  CARDINAL* = CTR.CARDINAL;

PROCEDURE InitTimer*;
BEGIN Measures.InitTimer
END InitTimer;

PROCEDURE FreeTimer*;
BEGIN Measures.FreeTimer;
END FreeTimer;

PROCEDURE GetTimer*( 
   VAR elapsed:   (*DateTime.*)TimeType;
   VAR cputime:   CARDINAL;
   VAR bufio:     CARDINAL;
   VAR dirio:     CARDINAL;
   VAR pagefault: CARDINAL );
BEGIN Measures.GetTimer(elapsed, cputime, bufio, dirio, pagefault);
END GetTimer;

PROCEDURE ShowTimer*;
BEGIN Measures.ShowTimer;
END ShowTimer;

PROCEDURE Time*(VAR time: TimeType);
BEGIN GetConvTime.Time(time);
END Time;

PROCEDURE Date*(VAR date: ARRAY OF CHAR);
BEGIN GetConvTime.Date(date);
END Date;

PROCEDURE ConvertTime*(time: TimeType; VAR date: ARRAY OF CHAR); 
BEGIN GetConvTime.ConvertTime(time,date);
END ConvertTime;

PROCEDURE ConvertDate*(date: ARRAY OF CHAR; VAR time: TimeType); 
BEGIN GetConvTime.ConvertDate(date, time);
END ConvertDate;

PROCEDURE Year*(time: TimeType): CTR.CARDINAL;       
BEGIN RETURN GetConvTime.Year(time) END Year;

PROCEDURE Month*(time: TimeType): CTR.CARDINAL;      
BEGIN RETURN GetConvTime.Month(time) END Month;

PROCEDURE Day*(time: TimeType): CTR.CARDINAL;        
BEGIN RETURN GetConvTime.Day(time) END Day;

PROCEDURE Hours*(time: TimeType): CTR.CARDINAL;      
BEGIN RETURN GetConvTime.Hours(time) END Hours;

PROCEDURE Minutes*(time: TimeType): CTR.CARDINAL;    
BEGIN RETURN GetConvTime.Minutes(time) END Minutes;

PROCEDURE Seconds*(time: TimeType): CTR.CARDINAL;    
BEGIN RETURN GetConvTime.Seconds(time) END Seconds;

PROCEDURE Hundredths*(time: TimeType): CTR.CARDINAL; 
BEGIN RETURN GetConvTime.Hundredths(time) END Hundredths;

END TimerServices.

___________________________________________________________________

MODULE TestSeq;
(*
  Test program for
  ISO 10154 Modula-2 Standard Library [Extension] of

  A2O|H2O V4 Modula-2 Compiler for AXP|VAX/OpenVMS
  Distribution Kit

Copyright (1994) Guenter Dotzel, ModulaWare,
http://www.modulaware.com/
This software source code constitutes intellectual property rights of Guenter Dotzel, ModulaWare and is furnished under a Non-Disclosure Agreement and may only be used, processed and stored according to the terms and conditions of this agreement.

All rights reserved.

This is an extended performance test program written in Oberon-2 for the ISO Modula-2 Std I/O-Lib. TestSeq reads/writes whole data structures and single bytes from/to binary and text files and evaluates the individual data transfer speed in Bytes/Second (elapsed- and CPU-time). The actual timings when run on a VAX and AXP workstations are also provided below. when comparing the speed with other libs, note that run-time checks are still enabled in our ISO M2 Std library implementation. Also, the elapsed time is varying and depends heavily on the server activities.

TestSeq creates two temporary files: BINA.LIS and TEXT.LIS which are truncated to zero size ad the end.

A Modula-2 version of TestSeq is also available on request.


Written by Elmar Baumgart, 01-Sep-1992.
Revised by GD/27-May-1994: 
 - variable parameters for check procedures,
 - upper limit increased for performance test (timer resolution is too low)
 - increased repeat count
*)

IMPORT IOResult, SeqFile, TextIO, SWholeIO, STextIO, RawIO,
  TimerServices, SYSTEM; (* avoid import of RealIO to be able to compile
  this module with the Eval Kit *)

CONST
  Check = TRUE; (* enable/disable io read checks *)

  BigBlocks = 1;
  Blocks = 1;
  Bytes = 1;

  lenB = ((BigBlocks * 63 + Blocks) * 512 + Bytes);
  lenT = 8190;

TYPE
  CARDINAL = LONGINT;
  INTEGER  = LONGINT;
  DataB = ARRAY lenB OF CHAR;
  DataT = ARRAY lenT OF CHAR;

CONST
  bin = 'BINA.LIS';
  tex = 'TEXT.LIS';

  F = 8;
  RepeatI = F*17000; (* integers written binary *)
  RepeatB = F*2;     (* binary fields           *)
  RepeatT = F*8;     (* text fields             *)
                  (* approx. F*64K for each test*)
  SizeI = SIZE(INTEGER) * RepeatI;
  SizeB = SIZE(DataB) * RepeatB;
  SizeT = SIZE(DataT) * RepeatT;

VAR
  f: SeqFile.ChanId; ores: SeqFile.OpenResults;
  i,j: INTEGER;
  ch, chRead: CHAR; eq: BOOLEAN;

  elapsed:   TimerServices.TimeType;
  cputime:   CARDINAL;
  bufio:     CARDINAL;
  dirio:     CARDINAL;
  pagefault: CARDINAL;

  fieldB, lastB: DataB;
  fieldT, lastLine: DataT;

  PROCEDURE InitFields(VAR t: DataT; VAR b: DataB);
  VAR ch: CHAR; i: INTEGER;
  BEGIN
    FOR i:= 0 TO lenB-1 DO b[i]:= CHR(i MOD 256);
    END;
    ch:= ' ';
    FOR i:= 0 TO lenT-1 DO
      t[i]:= ch; ch:= CHR(ORD(ch) + 1);
      IF ch = CHR(255) THEN ch:= ' ';
      END;
    END;
  END InitFields;

  PROCEDURE IsCorrectB((**)VAR(**) a: DataB): BOOLEAN;
  VAR i: INTEGER; eq: BOOLEAN;
  BEGIN
    i:= 0;
    eq:= a[i] = CHR(i MOD 256);
    WHILE eq & (i < lenB-1) DO
      INC(i); eq:= a[i] = CHR(i MOD 256);
    END;
    RETURN eq;
  END IsCorrectB;

  PROCEDURE IsCorrectT((**)VAR(**)a: DataT): BOOLEAN;
  VAR ch: CHAR; i: INTEGER; eq: BOOLEAN;
  BEGIN
    ch:= ' '; i:= 0;
    eq:= a[i] = ch;
    WHILE eq & (i < lenT-1) DO
      INC(i); ch:= CHR(ORD(ch) + 1);
      IF ch = CHR(255) THEN ch:= ' ';
      END;
      eq:= a[i] = ch;
    END;
    RETURN eq;
  END IsCorrectT;

  PROCEDURE Float(i: INTEGER): REAL;
  BEGIN RETURN i; (*FLOAT(i);*)
  END Float;
  
  PROCEDURE Header;
  BEGIN (* '                    ' *)
    STextIO.WriteLn;
    STextIO.WriteLn;
    STextIO.WriteString('                    ');
    STextIO.WriteString('   Kbytes/sec  Kbytes/cpusec');
    STextIO.WriteLn;
    STextIO.WriteString('                    ');
    STextIO.WriteString('transfer rate  transfer rate  bufio  dirio  pagefaults');
    STextIO.WriteLn; STextIO.WriteLn;
  END Header;

  PROCEDURE InitTimer;
  VAR i: INTEGER;
  BEGIN TimerServices.InitTimer;
  END InitTimer;

  PROCEDURE Info(a: ARRAY OF CHAR; Size: CARDINAL);
  VAR t: CARDINAL;
  BEGIN (* cputime is in 10 ms units *)
    TimerServices.GetTimer(elapsed, cputime, bufio, dirio, pagefault);
    cputime := cputime*10; (* convert to 1 ms units *)
    t:= 10*TimerServices.Hundredths(elapsed)+1000*TimerServices.Seconds(elapsed)
      +60000*TimerServices.Minutes(elapsed); (* t is in 1 ms units *)

    STextIO.WriteString(a); STextIO.WriteString('  ');
    IF t > 0 THEN
      SWholeIO.WriteInt(ENTIER(Float(Size)/Float(t)), 11);
    ELSE (* assume it took up-to 10 ms *)
      (* resolution of timer is not sufficient; avoid div by zero *)
      STextIO.WriteChar(">");
      SWholeIO.WriteInt(Size, 10);
    END;
    STextIO.WriteString('  ');
    IF cputime > 0 THEN 
      SWholeIO.WriteInt(ENTIER(Float(Size)/Float(cputime)), 13);
    ELSE (* assume it took up-to 10 ms *)
      STextIO.WriteChar(">"); (*div by zero*)
      SWholeIO.WriteInt(Size, 12);
    END;
    SWholeIO.WriteInt(bufio, 7);
    SWholeIO.WriteInt(dirio, 7);
    SWholeIO.WriteInt(pagefault,12);
    STextIO.WriteLn;
  END Info;

BEGIN
  STextIO.WriteLn;
  STextIO.WriteString('test of SeqFile, binary and text'); STextIO.WriteLn;
  STextIO.WriteString('-init fields-'); STextIO.WriteLn;

  InitFields(fieldT, fieldB);
  Header;
  SeqFile.OpenWrite(f, tex, SeqFile.read + SeqFile.text, ores);
  IF ores = SeqFile.opened THEN

    InitTimer;
    FOR i:= 1 TO RepeatT DO
      TextIO.WriteString(f, fieldT); TextIO.WriteLn(f);
    END;
    Info('       writing text ', SizeT);

    SeqFile.Rewrite(f);
    InitTimer;
    FOR i:= 1 TO RepeatT DO
      TextIO.WriteString(f, fieldT); TextIO.WriteLn(f);
    END;
    Info('       writing text ', SizeT);

    SeqFile.Rewrite(f);
    InitTimer;
    FOR i:= 1 TO RepeatT DO
      FOR j:=0 TO lenT-1 DO
        TextIO.WriteChar(f, fieldT[j]);
      END;
      TextIO.WriteLn(f);
    END;
    Info('write text bytewise ', SizeT);
    STextIO.WriteLn;

    SeqFile.Reread(f);
    i:= 0;
    InitTimer;
    TextIO.ReadRestLine(f, fieldT);
    WHILE (IOResult.ReadResult(f) # IOResult.endOfInput) DO
      INC(i); TextIO.SkipLine(f);
      IF Check THEN lastLine:= fieldT;
      END;
      TextIO.ReadRestLine(f, fieldT);
    END;
    Info('       reading text ', SizeT);
    IF Check & (~ IsCorrectT(lastLine) OR (i # RepeatT)) THEN
      SWholeIO.WriteInt(i, 5); STextIO.WriteString(' lines read'); STextIO.WriteLn;
      STextIO.WriteString('TestSeq-err: read text failed'); HALT(20);
    END;

    SeqFile.Reread(f);
    i:=0; ch:= ' '; eq:= TRUE;
    InitTimer;
    TextIO.ReadChar(f, chRead);
    WHILE eq & (IOResult.ReadResult(f) # IOResult.endOfInput) DO
      IF (IOResult.ReadResult(f) = IOResult.endOfLine) THEN
        INC(i); TextIO.SkipLine(f); ch:= CHR(254);
      ELSE
        eq:= ch = chRead;
      END;
      ch:= CHR(ORD(ch) + 1);
      IF ch = CHR(255) THEN ch:= ' ';
      END;
      TextIO.ReadChar(f, chRead);
    END;
    Info(' read text bytewise ', SizeT);
    IF Check & (~ eq OR (i # RepeatT)) THEN
      SWholeIO.WriteInt(i, 5); STextIO.WriteString(' lines read'); STextIO.WriteLn;
      STextIO.WriteString('TestSeq-err: read text failed'); HALT(20);
    END;
    STextIO.WriteLn;

    SeqFile.Rewrite(f); (* dealloc disk space *)
    SeqFile.Close(f);
  ELSE STextIO.WriteString('TestSeq-err: OPENWRITE text failed'); HALT(20);
  END;

  SeqFile.OpenWrite(f, bin, SeqFile.read + SeqFile.raw, ores);
  IF ores = SeqFile.opened THEN

    InitTimer;
    FOR i:= 1 TO RepeatB DO
      RawIO.Write(f, fieldB);
    END;
    Info('     writing binary ', SizeB);

    SeqFile.Rewrite(f);
    InitTimer;
    FOR i:= 1 TO RepeatB DO
      RawIO.Write(f, fieldB);
    END;
    Info('     writing binary ', SizeB);

    SeqFile.Rewrite(f);
    InitTimer;
    FOR i:= 1 TO RepeatB DO
      FOR j:=0 TO lenB-1 DO
        RawIO.Write(f, fieldB[j]);
      END;
    END;
    Info(' write bin bytewise ', SizeB);
    STextIO.WriteLn;

    SeqFile.Reread(f);
    i:= 0;
    InitTimer;
    RawIO.Read(f, fieldB);
    WHILE (IOResult.ReadResult(f) # IOResult.endOfInput) DO
      INC(i); 
      IF Check THEN lastB:= fieldB;
      END;
      RawIO.Read(f, fieldB);
    END;
    Info('     reading binary ', SizeB);
    IF Check & (~ IsCorrectB(lastB) OR (i # RepeatB)) THEN
      STextIO.WriteString('TestSeq-err: read binary failed'); HALT(20);
    END;

    SeqFile.Reread(f);
    i:=0; eq:= TRUE;
    RawIO.Read(f, chRead);
    InitTimer;
    WHILE eq & (IOResult.ReadResult(f) # IOResult.endOfInput) DO
      eq:= chRead = CHR(i MOD 256);
      RawIO.Read(f, chRead);
      i:= (i + 1) MOD lenB;   (* must be 0 on eof *)
    END;
    Info('  read bin bytewise ', SizeB);
    IF Check & (~ eq OR (i # 0)) THEN
      STextIO.WriteString('TestSeq-err: read binary failed'); HALT(20);
    END;

    SeqFile.Rewrite(f);
    InitTimer;
    FOR i:= 1 TO RepeatI DO RawIO.Write(f, i);
    END;
    STextIO.WriteLn;
    Info(' write bin integers ', SizeI);

    SeqFile.Reread(f);
    i:= 1;
    RawIO.Read(f, j);
    WHILE (IOResult.ReadResult(f) # IOResult.endOfInput) DO
      IF Check & (i # j) THEN
        STextIO.WriteString('TestSeq-err: read binary integers failed'); HALT(20);
      END;
      RawIO.Read(f, i); INC(j);
    END;
    Info('  read bin integers ', SizeI);

    SeqFile.Rewrite(f);
    SeqFile.Close(f);
  ELSE STextIO.WriteString('TestSeq-err: OPENWRITE binary failed'); HALT(20);
  END;
END TestSeq.

___________________________________________________________________

$ a2o testseqo
AXP/VMS Oberon-2 A2O V1.31 (C)1994 by ModulaWare GmbH, D91054 Erlangen/FRG
 compiling PSLAVE::DKA0:[000000.EDISON.OBERON2.OLI]TESTSEQO.MOD;94/NOCHECK
/DEBUG/NOPACK_RECORDS/NAME_SEPARATOR/NOTRANSFER_VECTOR
 IOResult: DKA300:[EDISON.OBERON2]IORESULT.SYN;2
 SeqFile: DKA300:[EDISON.OBERON2]SEQFILE.SYN;2
 TextIO: DKA300:[EDISON.OBERON2]TEXTIO.SYN;2
 SRealIO: DKA300:[EDISON.OBERON2]SREALIO.SYN;2
 SWholeIO: DKA300:[EDISON.OBERON2]SWHOLEIO.SYN;4
 STextIO: DKA300:[EDISON.OBERON2]STEXTIO.SYN;4
 RawIO: DKA300:[EDISON.OBERON2]RAWIO.SYN;2
 GetConvTime: DKA300:[EDISON.OBERON2]GETCONVTIME.SYN;2
 Measures: DKA300:[EDISON.OBERON2]MEASURES.SYN;4
 EXCEPTIONS: DKA300:[EDISON.OBERON2]EXCEPTIONS.SYN;2
%H2O-W-NEWSF, New symbol file generated: DKA300:[EDISON.OBERON2]TESTSEQO.SYN;4
%H2O-I-CODGEN, back-end: code generation
%H2O-I-CODAS, code size=   6800, data size=       82088
End of compilation, source file: PSLAVE::DKA0:[000000.EDISON.OBERON2.OLI]TESTSEQO.MOD
;94
$ link TESTSEQO
$run TESTSEQO/NODEB

test of SeqFile, binary and text
-init fields-

                       Kbytes/sec  Kbytes/cpusec
                    transfer rate  transfer rate  bufio  dirio  pagefaults

       writing text           66.           472.     32    240          15
       writing text          191.           749.      0     64           0
write text bytewise           10.            11.      0     64           0

       reading text          118.           224.      0     64          16
 read text bytewise            7.             8.     30    256           4

     writing binary           88.           718.     24    266          49
     writing binary          214.          1808.      0     32           0
 write bin bytewise            7.             9.     15   1120           0

     reading binary          239.          2383.      0     33          63
  read bin bytewise            6.             6.      0   1024           0

 write bin integers           15.            26.     15   1158           0
  read bin integers            8.            11.     31   2319           0
The above measurement was done on VAX/VMS V5.4 (VAXstation 3100/30). The below measurment was done on AXP/OpenVMS V6.1 (DEC 3000-300LX/125 MHz). Both compilations were with run-time array index checks disabled.

test of SeqFile, binary and text
-init fields-

                       Kbytes/sec  Kbytes/cpusec
                    transfer rate  transfer rate  bufio  dirio  pagefaults

       writing text          156.          1747.     32    162           2
       writing text          406.          4032.      0     64           0
write text bytewise           75.            95.      0     64           0

       reading text         1807.          1807.      0      1           0
 read text bytewise           46.            46.      0      0           0

     writing binary          270.          4369.      9     91           3
     writing binary          583.          8738.      0     32           0
 write bin bytewise           23.            47.      0   1024           0

     reading binary        10486.          8738.      0      1           3
  read bin bytewise           38.            38.      0      0           0

 write bin integers           39.           139.      0   1062           0
  read bin integers           30.            67.      1   1065           0
$
___________________________________________________________________

Strings Library

___________________________________________________________________ MODULE Strings; IMPORT CTR; CONST less* = 0; equal* = 1; greater* = 2; TYPE String1* = ARRAY 1 OF CHAR; CompareResults* = CTR.ENUM8; PROCEDURE Length*(StringVal: ARRAY OF CHAR): CTR.CARDINAL; END Length; PROCEDURE Assign*( Source: ARRAY OF CHAR; VAR Destination: ARRAY OF CHAR ); END Assign; PROCEDURE Extract*( Source: ARRAY OF CHAR; StartIndex, NumberToExtract: CTR.CARDINAL; VAR Destination: ARRAY OF CHAR ); END Extract; PROCEDURE Delete*( VAR StringValue: ARRAY OF CHAR; StartIndex, NumberToDelete: CTR.CARDINAL ); END Delete; PROCEDURE Insert*( Source: ARRAY OF CHAR; StartIndex: CTR.CARDINAL; VAR Destination: ARRAY OF CHAR ); END Insert; PROCEDURE Replace*( Source: ARRAY OF CHAR; StartIndex: CTR.CARDINAL; VAR Destination: ARRAY OF CHAR ); END Replace; PROCEDURE Append*( Source: ARRAY OF CHAR; VAR Destination: ARRAY OF CHAR ); END Append; PROCEDURE Concat*( Source1, Source2: ARRAY OF CHAR; VAR Destination: ARRAY OF CHAR ); END Concat; PROCEDURE Capitalize*( VAR StringVar: ARRAY OF CHAR ); END Capitalize; PROCEDURE Compare*( StringVal1, StringVal2: ARRAY OF CHAR ): CompareResults; END Compare; PROCEDURE Equal*( StringVal1, StringVal2: ARRAY OF CHAR ): BOOLEAN; END Equal; PROCEDURE FindNext*( Pattern, StringValue: ARRAY OF CHAR; StartIndex: CTR.CARDINAL; VAR PatternFound: BOOLEAN; VAR PosOfPattern: CTR.CARDINAL ); END FindNext; PROCEDURE FindPrev*( Pattern, StringValue: ARRAY OF CHAR; StartIndex: CTR.CARDINAL; VAR PatternFound: BOOLEAN; VAR PosOfPattern: CTR.CARDINAL ); END FindPrev; PROCEDURE FindDiff*( StringVal1, StringVal2: ARRAY OF CHAR; VAR DifferenceFound: BOOLEAN; VAR PosOfDifference: CTR.CARDINAL ); END FindDiff; PROCEDURE CanAssignAll*( SourceLength: CTR.CARDINAL; VAR Destination: ARRAY OF CHAR ): BOOLEAN; END CanAssignAll; PROCEDURE CanExtractAll*( SourceLength, StartIndex, NumberToExtract: CTR.CARDINAL; VAR Destination: ARRAY OF CHAR ): BOOLEAN; END CanExtractAll; PROCEDURE CanDeleteAll*( StringLength, StartIndex, NumberToDelete: CTR.CARDINAL ): BOOLEAN; END CanDeleteAll; PROCEDURE CanInsertAll*( SourceLength, StartIndex: CTR.CARDINAL; VAR Destination: ARRAY OF CHAR ): BOOLEAN; END CanInsertAll; PROCEDURE CanReplaceAll*( SourceLength, StartIndex: CTR.CARDINAL; VAR Destination: ARRAY OF CHAR ): BOOLEAN; END CanReplaceAll; PROCEDURE CanAppendAll*( SourceLength: CTR.CARDINAL; VAR Destination: ARRAY OF CHAR ): BOOLEAN; END CanAppendAll; PROCEDURE CanConcatAll*( Source1Length, Source2Length: CTR.CARDINAL; VAR Destination: ARRAY OF CHAR ): BOOLEAN; END CanConcatAll; END Strings. ___________________________________________________________________

Storage Library

___________________________________________________________________ MODULE Storage; (* Oberon-2 module for H2O by GD/23-Sep-1993 *) IMPORT CTR, SYSTEM, lib:=LIB$ (*,EXCEPTIONS*); (* TYPE StorageExceptions*=CTR.ENUM8; CONST nilDeallocation*=0; pointerToUnallocatedStorage*=1; wrongStorageToUnallocate*=2; VAR ExSource: EXCEPTIONS.ExceptionSource; *) PROCEDURE ALLOCATE*(VAR v: CTR.ADDRESS; n: CTR.CARDINAL); VAR Result: CTR.CARDINAL; BEGIN Result := lib.LIB$GET_VM (n, v); IF ~ ODD(Result) THEN lib.LIB$SIGNAL(Result) END; END ALLOCATE; PROCEDURE DEALLOCATE*(VAR v: CTR.ADDRESS; n: CTR.CARDINAL); VAR Result: CTR.CARDINAL; BEGIN Result := lib.LIB$FREE_VM (n, v); IF ~ ODD(Result) THEN lib.LIB$SIGNAL(Result) END; v := SYSTEM.VAL(CTR.ADDRESS,NIL); END DEALLOCATE; (* PROCEDURE IsStorageException* (): BOOLEAN; BEGIN RETURN FALSE; END IsStorageException; PROCEDURE StorageException* (): StorageExceptions; BEGIN EXCEPTIONS.RAISE(ExSource, 1, 'm2-iso-lib-err: procedure StorageException not avail able'); RETURN nilDeallocation; (* dummy return *) END StorageException; *) END Storage. ___________________________________________________________________

Mathematical Library

__________________________________________________________________ MODULE RealMath; IMPORT CTR; TYPE INTEGER = CTR.INTEGER; CONST pi* = 3.1415926535897932384626433832795028841972; exp1* = 2.7182818284590452353602874713526624977572; PROCEDURE sqrt*(x: REAL): REAL; END sqrt; PROCEDURE exp*(x: REAL): REAL; END exp; PROCEDURE ln*(x: REAL): REAL; END ln; PROCEDURE sin*(x: REAL): REAL; END sin; PROCEDURE cos*(x: REAL): REAL; END cos; PROCEDURE tan*(x: REAL): REAL; END tan; PROCEDURE arcsin*(x: REAL): REAL; END arcsin; PROCEDURE arccos*(x: REAL): REAL; END arccos; PROCEDURE arctan*(x: REAL): REAL; END arctan; PROCEDURE power*(base, exponent: REAL): REAL; END power; PROCEDURE round*(x: REAL): INTEGER; END round; PROCEDURE IsRMathException*(): BOOLEAN; END IsRMathException; END RealMath. ___________________________________________________________________ MODULE LongMath; IMPORT CTR; TYPE INTEGER = CTR.INTEGER; CONST pi* = 3.1415926535897932384626433832795028841972D+0; exp1* = 2.7182818284590452353602874713526624977572D+0; PROCEDURE sqrt*(x: LONGREAL): LONGREAL; END sqrt; PROCEDURE exp*(x: LONGREAL): LONGREAL; END exp; PROCEDURE ln*(x: LONGREAL): LONGREAL; END ln; PROCEDURE sin*(x: LONGREAL): LONGREAL; END sin; PROCEDURE cos*(x: LONGREAL): LONGREAL; END cos; PROCEDURE tan*(x: LONGREAL): LONGREAL; END tan; PROCEDURE arcsin*(x: LONGREAL): LONGREAL; END arcsin; PROCEDURE arccos*(x: LONGREAL): LONGREAL; END arccos; PROCEDURE arctan*(x: LONGREAL): LONGREAL; END arctan; PROCEDURE power*(base, exponent: LONGREAL): LONGREAL; END power; PROCEDURE round*(x: LONGREAL): INTEGER; END round; PROCEDURE IsRMathException*(): BOOLEAN; END IsRMathException; END LongMath. ___________________________________________________________________ MODULE ComplexMath; IMPORT SYSTEM; TYPE COMPLEX* = SYSTEM.F_COMPLEX; REAL*= SYSTEM.F_FLOATING; (*AS*) PROCEDURE abs*(z: COMPLEX): REAL; END abs; PROCEDURE arg*(z: COMPLEX): REAL; END arg; PROCEDURE conj*(z: COMPLEX): COMPLEX; END conj; PROCEDURE power*(base: COMPLEX; exponent: REAL): COMPLEX; END power; PROCEDURE sqrt*(z: COMPLEX): COMPLEX; END sqrt; PROCEDURE exp*(z: COMPLEX): COMPLEX; END exp; PROCEDURE ln*(z: COMPLEX): COMPLEX; END ln; PROCEDURE sin*(z: COMPLEX): COMPLEX; END sin; PROCEDURE cos*(z: COMPLEX): COMPLEX; END cos; PROCEDURE tan*(z: COMPLEX): COMPLEX; END tan; PROCEDURE arcsin*(z: COMPLEX): COMPLEX; END arcsin; PROCEDURE arccos*(z: COMPLEX): COMPLEX; END arccos; PROCEDURE arctan*(z: COMPLEX): COMPLEX; END arctan; PROCEDURE polarToComplex*(abs, arg: REAL): COMPLEX; END polarToComplex; PROCEDURE scalarMult*(scalar: REAL; z: COMPLEX): COMPLEX; END scalarMult; PROCEDURE IsCMathException* (): BOOLEAN; END IsCMathException; END ComplexMath. ___________________________________________________________________ MODULE LongComplexMath; IMPORT SYSTEM; TYPE LONGCOMPLEX* = SYSTEM.D_COMPLEX; LONGREAL* = SYSTEM.D_FLOATING; (*AS*) PROCEDURE abs*(z: LONGCOMPLEX): LONGREAL; END abs; PROCEDURE arg*(z: LONGCOMPLEX): LONGREAL; END arg; PROCEDURE conj*(z: LONGCOMPLEX): LONGCOMPLEX; END conj; PROCEDURE power*(base: LONGCOMPLEX; exponent: LONGREAL): LONGCOMPLEX; END power; PROCEDURE sqrt*(z: LONGCOMPLEX): LONGCOMPLEX; END sqrt; PROCEDURE exp*(z: LONGCOMPLEX): LONGCOMPLEX; END exp; PROCEDURE ln*(z: LONGCOMPLEX): LONGCOMPLEX; END ln; PROCEDURE sin*(z: LONGCOMPLEX): LONGCOMPLEX; END sin; PROCEDURE cos*(z: LONGCOMPLEX): LONGCOMPLEX; END cos; PROCEDURE tan*(z: LONGCOMPLEX): LONGCOMPLEX; END tan; PROCEDURE arcsin*(z: LONGCOMPLEX): LONGCOMPLEX; END arcsin; PROCEDURE arccos*(z: LONGCOMPLEX): LONGCOMPLEX; END arccos; PROCEDURE arctan*(z: LONGCOMPLEX): LONGCOMPLEX; END arctan; PROCEDURE polarToComplex*(abs, arg: LONGREAL): LONGCOMPLEX; END polarToComplex; PROCEDURE scalarMult*(scalar: LONGREAL; z: LONGCOMPLEX): LONGCOMPLEX; END scalarMult; PROCEDURE IsCMathException* (): BOOLEAN; END IsCMathException; END LongComplexMath. ___________________________________________________________________

Low-level Real-number Representation Support

___________________________________________________________________ MODULE LowReal; IMPORT CTR; CONST radix *= 2; places *= 23; expoMin *= -127; expoMax *= 127; large *= MAX(REAL); small *= 2.938736E-37*1.E-2; IEEE *= FALSE; ISO *= FALSE; rounds *= FALSE; gUnderflow *= FALSE; exception *= FALSE; extend *= FALSE; nModes *= 1; TYPE INTEGER *= CTR.INTEGER; Modes *= SET (*OF [0 .. nModes-1]*); PROCEDURE exponent *(x: REAL): INTEGER; END exponent; PROCEDURE fraction *(x: REAL): REAL; END fraction; PROCEDURE sign *(x: REAL): REAL; END sign; PROCEDURE succ *(x: REAL): REAL; END succ; PROCEDURE ulp *(x: REAL): REAL; END ulp; PROCEDURE pred *(x: REAL): REAL; END pred; PROCEDURE intpart *(x: REAL): REAL; END intpart; PROCEDURE fractpart *(x: REAL): REAL; END fractpart; PROCEDURE scale *(x: REAL; n: INTEGER): REAL; END scale; PROCEDURE trunc *(x: REAL; n: INTEGER): REAL; END trunc; PROCEDURE round *(x: REAL; n: INTEGER): REAL; END round; PROCEDURE synthesize *(expart: INTEGER; frapart: REAL): REAL; END synthesize; PROCEDURE setMode *(m: Modes); END setMode; PROCEDURE currentMode *(): Modes; END currentMode; PROCEDURE IsLowException *(): BOOLEAN; END IsLowException; END LowReal. ___________________________________________________________________ MODULE LowLong; IMPORT CTR, SYSTEM; CONST radix *= 2; places *= 23 + 32; expoMin *= -127; expoMax *= 127; large *= MAX (LONGREAL); small *= 2.93873587705571878D-35 *1.D-1 *1.D-1 *1.D-1 *1.D-1; (*temporary for H2O, adjusted for OP2 scanner to produce exactly 000000000000080H *) IEEE *= FALSE; ISO *= FALSE; rounds *= FALSE; gUnderflow *= FALSE; exception *= FALSE; extend *= FALSE; nModes *= 1; TYPE INTEGER *= CTR.INTEGER; Modes *= SET(* OF [0 .. nModes-1]*); PROCEDURE exponent *(x: LONGREAL): INTEGER; END exponent; PROCEDURE fraction *(x: LONGREAL): LONGREAL; END fraction; PROCEDURE sign *(x: LONGREAL): LONGREAL; END sign; PROCEDURE succ *(x: LONGREAL): LONGREAL; END succ; PROCEDURE ulp *(x: LONGREAL): LONGREAL; END ulp; PROCEDURE pred *(x: LONGREAL): LONGREAL; END pred; PROCEDURE intpart *(x: LONGREAL): LONGREAL; END intpart; PROCEDURE fractpart *(x: LONGREAL): LONGREAL; END fractpart; PROCEDURE scale *(x: LONGREAL; n: INTEGER): LONGREAL; END scale; PROCEDURE trunc *(x: LONGREAL; n: INTEGER): LONGREAL; END trunc; PROCEDURE round *(x: LONGREAL; n: INTEGER): LONGREAL; END round; PROCEDURE synthesize *(expart: INTEGER; frapart: LONGREAL): LONGREAL; END synthesize; PROCEDURE setMode *(m: Modes); END setMode; PROCEDURE currentMode *(): Modes; END currentMode; PROCEDURE IsLowException (): BOOLEAN; END IsLowException; END LowLong. ___________________________________________________________________

Concurrent Processes Library

___________________________________________________________________ MODULE Processes; IMPORT CTR; TYPE ProcessId* = POINTER TO ProcessIdDesc; ProcessIdDesc*= RECORD END; (* hidden type *) Parameter* = CTR.ADDRESS; Body* = PROCEDURE; Urgency* = CTR.INTEGER; Sources* = CTR.CARDINAL; ProcessesExceptions* = CTR.ENUM8; CONST passiveProgram*=0; processError*=1; PROCEDURE Create*(procBody: Body; extraSpace: CTR.CARDINAL; procUrg: Urgency; procParams: Parameter; VAR procId: ProcessId); END Create; PROCEDURE Start*(procBody: Body; extraSpace: CTR.CARDINAL; procUrg: Urgency; procParams: Parameter; VAR procId: ProcessId); END Start; PROCEDURE StopMe*(); END StopMe; PROCEDURE SuspendMe*(); END SuspendMe; PROCEDURE Activate*(procId: ProcessId); END Activate; PROCEDURE SuspendMeAndActivate*(procId: ProcessId); END SuspendMeAndActivate; PROCEDURE Switch*(procId: ProcessId; VAR info: Parameter ); END Switch; PROCEDURE Wait*(); END Wait; PROCEDURE Attach*(eventSource: Sources); END Attach; PROCEDURE Detach*(eventSource: Sources); END Detach; PROCEDURE IsAttached*(eventSource: Sources): BOOLEAN; END IsAttached; PROCEDURE Handler*(eventSource: Sources): ProcessId; END Handler; PROCEDURE Me*(): ProcessId; END Me; PROCEDURE MyParam*(): Parameter; END MyParam; PROCEDURE UrgencyOf*(procId: ProcessId): Urgency; END UrgencyOf; PROCEDURE ProcessesException*(): ProcessesExceptions; END ProcessesException; PROCEDURE IsProcessesException*(): BOOLEAN; END IsProcessesException; END Processes. ___________________________________________________________________ MODULE Semaphores; IMPORT CTR; TYPE SEMAPHORE* = POINTER TO SemaphoreDesc; SemaphoreDesc*=RECORD END; PROCEDURE Create*(VAR s: SEMAPHORE; initialCount: CTR.CARDINAL); END Create; PROCEDURE Destroy*(VAR s: SEMAPHORE); END Destroy; PROCEDURE Claim*(s: SEMAPHORE); END Claim; PROCEDURE Release*(s: SEMAPHORE); END Release; PROCEDURE CondClaim*(s: SEMAPHORE): BOOLEAN; END CondClaim; END Semaphores. ___________________________________________________________________

IMPRESSUM: The ModulaTor is an unrefereed journal. Technical papers are to be taken as working papers and personal rather than organizational statements. Items are printed at the discretion of the Editor based upon his judgement on the interest and relevancy to the readership. Letters, announcements, and other items of professional interest are selected on the same basis. Office of publication. The Editor of The ModulaTor is Günter Dotzel; he can be reached at mailto:[email deleted due to spam]


Home | Site_index | Legal | OpenVMS_compiler | Alpha_Oberon_System | ModulaTor | Bibliography | Oberon[-2]_links | Modula-2_links |

Amazon.com [3KB] [Any browser]

Books Music Video Enter keywords...


Amazon.com logo

Webdesign by www.otolo.com/webworx, 16-Dec-1998