DEFINITION MODULE FormulVars;
(*******************************************************************
Module FormulVars (Version 1.0)
Copyright (c) 1993-2006 by Andreas Fischlin and ETH Zurich.
Purpose Declaration and removal of real variables
identified via identifiers.
Remarks These variables may form part of formulas that
are given in form of string expressions.
See companion module FormulIntrpr for the
evaluation respectively numerical interpretation
of expressions built with variables from this module.
This module supports only a single scope, thus
any identifier must be uniquely associated with a
corresponding real variable in the client
program.
Programming
o Design
Andreas Fischlin 02/06/1993
o Implementation
Andreas Fischlin 02/06/1993
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: 07/06/1993 FT
*******************************************************************)
FROM SYSTEM IMPORT ADDRESS;
CONST
noAttr = NIL;
noReal = NIL;
TYPE
RealPtr = POINTER TO REAL;
AttributePtr = ADDRESS;
(* In the following procedures the formal parameter ident is VAR
only for efficiency reasons: *)
PROCEDURE DeclareVar ( ident: ARRAY OF CHAR;
VAR x : REAL;
attr : AttributePtr);
PROCEDURE RecordVar (VAR ident: ARRAY OF CHAR;
VAR x : REAL;
attr : AttributePtr);
(* ==========
These two functionally identical procedures allow to record a
real variable x with the identifier ident. An optional
attribute can be associated with x, which can hold a pointer
to any data structure, e.g. describing the variable etc. *)
PROCEDURE IsVar (VAR ident: ARRAY OF CHAR;
VAR v: REAL; VAR realPtr: RealPtr): BOOLEAN;
(* =====
Returns TRUE if the variable denoted by ident is currently
installed, i.e. has been declared by a call to either DeclareVar
or RecordVar, else FALSE. Its current value is returned in v; the
pointer to the associated real variable from the client module is
returned in realPtr; if not installed v contains
DMConversions.UndefREAL (=NAN(017)) and realPtr NoReal() [s.b.]. *)
PROCEDURE VarVal (VAR ident: ARRAY OF CHAR): REAL;
(* ======
Returns the current value of the real variable from the client
module, which is associated with the variable denoted by ident.
If the variable is currently not installed
DMConversions.UndefREAL (=NAN(017)) is returned. *)
PROCEDURE VarPtr (VAR ident: ARRAY OF CHAR): RealPtr;
(* ======
Returns the pointer to the real variable from the client module,
which is associated with the variable denoted by ident. If the
variable is currently not installed, NoReal() [s.b.] is returned. *)
PROCEDURE VarAttr (VAR ident: ARRAY OF CHAR): AttributePtr;
(* =======
Returns the attribute associated with the variable denoted
by ident. If the variable is currently not installed, NoAttr()
[s.b.] is returned. *)
PROCEDURE UndeclareVar ( ident: ARRAY OF CHAR);
PROCEDURE DeleteVar (VAR ident: ARRAY OF CHAR);
(* ============
Deletes the variable with the identifier ident. The two procedures
are functionally identical. *)
PROCEDURE DiscardAllVars;
(* ==============
Undeclares all presently declared variables. *)
END FormulVars.