home *** CD-ROM | disk | FTP | other *** search
Modula Definition | 1996-07-31 | 6.0 KB | 153 lines |
- DEFINITION MODULE MiscM2;
-
- (********************************************************)
- (* *)
- (* Miscellaneous utility procedures *)
- (* *)
- (* Programmer: P. Moylan *)
- (* Last edited: 31 July 1996 *)
- (* Status: OK *)
- (* *)
- (* The purpose of this module is to provide *)
- (* the non-portable part of a numerical *)
- (* analysis package - i.e. to separate out the *)
- (* library dependencies, so that most of the *)
- (* work in porting the software to another *)
- (* compiler or library lies in rewriting this *)
- (* (simple) module. *)
- (* *)
- (* Many of the procedures here relate to output *)
- (* to a screen window. For use in an environment *)
- (* which does not support screen windows, you *)
- (* simply have to replace the definition of *)
- (* type "Window" by a dummy definition, and let *)
- (* the implementation ignore the "Window" *)
- (* parameters. *)
- (* *)
- (* One catch with the present approach is that *)
- (* it requires the concept of the "current *)
- (* window". Do not attempt to use this module *)
- (* in multitasking applications, because if *)
- (* more than one task is doing screen output *)
- (* then there is an ambiguity in what constitutes *)
- (* the current window. *)
- (* *)
- (********************************************************)
-
- FROM SYSTEM IMPORT (*type*) ADDRESS;
- IMPORT LongMath;
-
- TYPE Window = CARDINAL; (* in this version, effectively a dummy definition *)
-
- (************************************************************************)
- (* MATHEMATICAL FUNCTIONS *)
- (************************************************************************)
-
- CONST PI = LongMath.pi;
-
- PROCEDURE Sqrt (x: LONGREAL): LONGREAL;
-
- (* Square root. *)
-
- PROCEDURE Exp (x: LONGREAL): LONGREAL;
-
- (* Exponential. *)
-
- PROCEDURE Log (x: LONGREAL): LONGREAL;
-
- (* Natural logarithm. *)
-
- PROCEDURE Power (x, y: LONGREAL): LONGREAL;
-
- (* Computes x to the power of y. *)
-
- PROCEDURE Sin (x: LONGREAL): LONGREAL;
-
- (* Sine of x (radians). *)
-
- PROCEDURE Cos (x: LONGREAL): LONGREAL;
-
- (* Cosine of x (radians). *)
-
- PROCEDURE ATan2 (x, y: LONGREAL): LONGREAL;
-
- (* Inverse tangent of y/x. Result is in range -PI to PI. *)
-
- (************************************************************************)
- (* MISCELLANEOUS UTILITIES *)
- (************************************************************************)
-
- PROCEDURE BlockCopy (source, destination: ADDRESS; bytecount: CARDINAL);
-
- (* Copies an array of bytes from the source address to the *)
- (* destination address. *)
-
- PROCEDURE AddOffset (A: ADDRESS; increment: CARDINAL): ADDRESS;
-
- (* Returns a pointer to the memory location whose physical address *)
- (* is Physical(A)+increment. It is assumed that the caller will *)
- (* never try to run off the end of a segment. *)
-
- PROCEDURE LongRealToString (number: LONGREAL;
- VAR (*OUT*) buffer: ARRAY OF CHAR;
- fieldsize: CARDINAL);
-
- (* Converts the number to a decimal character string in array *)
- (* "buffer", right-justified in a field of fieldsize characters. *)
- (* The format depends on the size of the number relative to the *)
- (* size of the buffer. *)
-
- (************************************************************************)
- (* SCREEN OUTPUT *)
- (************************************************************************)
-
- PROCEDURE SelectWindow (w: Window);
-
- (* Specifies that all screen output, up until the next call to *)
- (* SelectWindow, will be to window w. *)
-
- PROCEDURE WriteString (s: ARRAY OF CHAR);
-
- (* Writes s to the current window. *)
-
- PROCEDURE WriteLn;
-
- (* Writes an end-of-line to the current window. *)
-
- PROCEDURE PressAnyKey;
-
- (* "Press any key to continue". *)
-
- PROCEDURE Error (message: ARRAY OF CHAR);
-
- (* Puts a message to the screen. *)
-
- PROCEDURE WriteCard (N: CARDINAL);
-
- (* Writes a cardinal value. *)
-
- PROCEDURE WriteRJCard (number, fieldsize: CARDINAL);
-
- (* Like WriteCard, but the result is right justified in a field *)
- (* of fieldsize characters. *)
-
- PROCEDURE WriteReal (x: REAL; places: CARDINAL);
- PROCEDURE WriteLongReal (x: LONGREAL; places: CARDINAL);
-
- (* Writes x in a field "places" characters wide. *)
-
- (************************************************************************)
- (* KEYBOARD INPUT *)
- (************************************************************************)
-
- PROCEDURE ReadCard (VAR (*OUT*) N: CARDINAL);
-
- (* Reads a cardinal from the keyboard, echoing it to screen. *)
-
- PROCEDURE ReadLongReal(): LONGREAL;
-
- (* Reads and converts a numeric string from the keyboard. *)
-
- END MiscM2.
-
-