ETHZ_Logo RAMSES_Logo_Right   RAMSES   RAMSES_Logo_Left Systems Ecology  
Start    search button      Modules:   A-Z   Function   Layer        QuickRefs:   DM   AuxLib   AuxLibE   SciLib   EasyMW   MW   ISIS   RMSLib

DEFINITION MODULE DMPortab;

  (*******************************************************************

    Module  DMPortab     ('Dialog Machine' DM_V3.0)

      Copyright (c) 1995-2006 by Andreas Fischlin and ETH Zurich.

    Purpose   Support full portability of the source code of 
              'Dialog Machine' programs among Modula-2 compilers. 
              Since different platforms are likely to require 
              different compilers, this enhances also 
              cross-platform portability.

    Remarks   An example of such functions are the
              standard environment functions FLOATD
              (MacMETH) or LFLOAT (EPC Modula-2 Sun).
              Only those functions are provided by this
              module which can't be avoided by any other
              means (see also Thoeny, 1995.  Practical
              considerations on writing portable Modula-2
              code.  Systems Ecology Report No. 20, 6pp).

              This module belongs to the 'Dialog Machine'.


    Programming

      o Design
        Andreas Fischlin          14/11/1995

      o Implementation
        Andreas Fischlin          14/11/1995


    ETH Zurich
    Systems Ecology
    CHN E 35.1
    Universitaetstrasse 16
    8092 Zurich
    SWITZERLAND

    URLs:
        <mailto:RAMSES@env.ethz.ch>
        <http://www.sysecol.ethz.ch>
        <http://www.sysecol.ethz.ch/SimSoftware/RAMSES>


    Last revision of definition:  22/08/2004  AF

  *******************************************************************)


  FROM SYSTEM IMPORT BYTE;

  VAR
    zero, one,two, ten, hundred, thousand: LONGREAL;            (* read only *)
    zeroLI, oneLI,twoLI, tenLI, hundredLI, thousandLI: LONGINT; (* read only *)


  PROCEDURE SameProc (p1,p2: ARRAY OF BYTE): BOOLEAN;
    (*
      Compares two procedure variables for identity, i.e.
      whether the two variables have been assigned the same
      procedure or not.  Make sure you pass as actual arguments
      just two procedure variables, not an actual procedure
      identifier; some compilers, e.g.  the MacMETH compiler,
      might not accept the latter.
    *)


  PROCEDURE LIFLOAT(x: LONGINT): LONGREAL;
  PROCEDURE LCFLOAT(x: LONGCARD): LONGREAL;
  PROCEDURE LITRUNC(x: LONGREAL): LONGINT;
  PROCEDURE LCTRUNC(x: LONGREAL): LONGCARD;
    (*
      Allows for avoiding the use of non portable standard
      functions such as TRUNCD, LONGTRUNC etc.  in expressions,
      hereby enhancing the portability, albeit at the cost of
      efficiency.  However, these functions are implemented
      with the highest efficiency available on the particular
      machine
    *)


  PROCEDURE LONGINTConst(str: ARRAY OF CHAR): LONGINT;
  PROCEDURE LONGCARDConst(str: ARRAY OF CHAR): LONGCARD;
  PROCEDURE LONGREALConst(str: ARRAY OF CHAR): LONGREAL;
    (*
      Not very efficient, but highly portable way to force
      constants to be computed to highest possible precision.
      For instance 0.123456789012D (note the D at the end) is
      not a portable constant definition, but is required on
      the Mac by the MacMETH language in order to avoid
      truncation of this constant after the 7th digit.
      However, LONGREALConst("0.123456789012") will have the
      same effect (albeit not a true constant) and warrants a
      portable assignment of a double precision real (LONGREAL)
      or long integer (LONGINT) number.
    *)


  PROCEDURE LI(x: INTEGER ): LONGINT;
  PROCEDURE SI(x: LONGINT ): INTEGER;
  PROCEDURE LC(x: CARDINAL): LONGCARD;
  PROCEDURE SC(x: LONGCARD): CARDINAL;
  PROCEDURE LR(x: REAL    ): LONGREAL;
  PROCEDURE SR(x: LONGREAL): REAL;
    (*
      Since older Modula-2 language definitions did not
      recognize long elementary data types, some standard
      functions which accomplish type transfers vary from
      implementation to implementation.  Above routines provide
      fully portable type conversions between long and short
      types, which is convenient in mixed expressions.  The
      implementation exploits assignment compatibility between
      these types, which is normally available in all language
      implementations.
    *)


END DMPortab.

  Contact RAMSES@env.ethz.ch Last updated: 25-Jul-2011 [Top of page]