|
|
|
|
||
|
DEFINITION MODULE DatTabAccess; (******************************************************************* Module DatTabAccess (Version 1.0) Copyright (c) 1997-2006 by Dimitrios Gyalistras, Andreas Fischlin and ETH Zurich. Purpose Supports reading of data frames, retrieval of information from the data frames, and the assignment of the data to model objects. Remarks See also modules DataTables, Errors. Programming o Design Dimitrios Gyalistras 27/01/1997 Andreas Fischlin 04/03/1997 o Implementation Dimitrios Gyalistras 27/01/1997 Andreas Fischlin 04/03/1997 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: 24/10/1998 DG *******************************************************************) FROM DataTables IMPORT DataTable, DTElementType; (*---------------------------------------------------------------------------*) CONST unknownColNr = 0; unknownRowNr = 0; (*---------------------------------------------------------------------------*) PROCEDURE InitFastTableAccess( dt: DataTable ); PROCEDURE StopFastTableAccess; (* Call InitFastTableAccess to access a single table dt with maximum efficiency. Call StopFastTableAccess to give up eficient access to this table. *) (*---------------------------------------------------------------------------*) PROCEDURE ColNum( dt : DataTable; colID : ARRAY OF CHAR ): INTEGER; (* Returns order of column with ident colID in data table dt. Returns unknownColNr, if no such column exists. *) PROCEDURE ColType( dt : DataTable; colID : ARRAY OF CHAR ): DTElementType; (* Returns type of column with ident colID in data table dt. Returns DTElementType.unknownDTEle, if no such column exists. *) PROCEDURE ColTypeOK( dt : DataTable; colNr : INTEGER; expctdType : DTElementType ): BOOLEAN; (* Returns true if column colNr of table dt is of type expctdType. # Raises an error of type Errors.Halt if this is not the case. *) (*---------------------------------------------------------------------------*) PROCEDURE MaxRow ( dt : DataTable): INTEGER; PROCEDURE MaxCol ( dt : DataTable): INTEGER; (* Returns the number of rows/columns of table dt if it exists, otherwise returns unknownRowNr/unknownColNr. # Raises an error of type Errors.Halt if dt does not exist. *) PROCEDURE IDRowNum( dt : DataTable; colNr : INTEGER; theID : ARRAY OF CHAR ): INTEGER; (* Returns number rowNr of first found row in which ident theID occurs within column colNr of table dt. Returns unknownRowNr if the ident could not be found. # Raises an error of type Errors.Halt if column colNr is not of type DTElementType.ident. *) PROCEDURE StrRowNum( dt : DataTable; colNr : INTEGER; theStr : ARRAY OF CHAR ): INTEGER; (* Returns number rowNr of first found row in which string theStr occurs within column colNr of table dt. Returns unknownRowNr if the string could not be found. # Raises an error of type Errors.Halt if column colNr is not of type DTElementType.string. *) PROCEDURE IntRowNum( dt : DataTable; colNr : INTEGER; theInt : INTEGER ): INTEGER; (* Returns number rowNr of first found row in which integer theInt occurs within column colNr of table dt. Returns unknownRowNr if the integer could not be found. # Raises an error of type Errors.Halt if column colNr is not of type DTElementType.integer. *) PROCEDURE LIntRowNum( dt : DataTable; colNr : INTEGER; theLInt : LONGINT ): INTEGER; (* Returns number rowNr of first found row in which long integer theLInt occurs within column colNr of table dt. Returns unknownRowNr if the long integer could not be found. # Raises an error of type Errors.Halt if column colNr is not of type DTElementType.longint. *) (*---------------------------------------------------------------------------*) PROCEDURE SetInt ( dt: DataTable; rowNr,colNr: INTEGER; i: INTEGER ); PROCEDURE GetInt ( dt: DataTable; rowNr,colNr: INTEGER ): INTEGER; PROCEDURE SetLInt ( dt: DataTable; rowNr,colNr: INTEGER; li: LONGINT ); PROCEDURE GetLInt ( dt: DataTable; rowNr,colNr: INTEGER ): LONGINT; PROCEDURE SetReal ( dt: DataTable; rowNr,colNr: INTEGER; r: REAL ); PROCEDURE GetReal ( dt: DataTable; rowNr,colNr: INTEGER ): REAL; PROCEDURE SetLReal ( dt: DataTable; rowNr,colNr: INTEGER; lr: LONGREAL ); PROCEDURE GetLReal ( dt: DataTable; rowNr,colNr: INTEGER ): LONGREAL; PROCEDURE SetBool ( dt: DataTable; rowNr,colNr: INTEGER; b: BOOLEAN ); PROCEDURE GetBool ( dt: DataTable; rowNr,colNr: INTEGER ): BOOLEAN; PROCEDURE SetID ( dt: DataTable; rowNr,colNr: INTEGER; id : ARRAY OF CHAR ); PROCEDURE GetID ( dt: DataTable; rowNr,colNr: INTEGER; VAR id : ARRAY OF CHAR ); PROCEDURE SetString( dt: DataTable; rowNr,colNr: INTEGER; str: ARRAY OF CHAR ); PROCEDURE GetString( dt: DataTable; rowNr,colNr: INTEGER; VAR str: ARRAY OF CHAR ); (* Set/get the contents of cell with coordinates [rowNr,colNr] of data table dt. # All procedures raise an error of type Errors.Halt if row rowNr or column colNr is out of range, or if the requested element is of the wrong type. *) END DatTabAccess.
|
||
|
|
|