home *** CD-ROM | disk | FTP | other *** search
- --------------------------------------------------------------------------
- F i l e I n f o r m a t i o n
-
- * DESCRIPTION
- DECODE88.PAS will not work with TURBO-87 or TURBOCD.
- Requires: Turbo Pascal 2.0, 3.0. Author: Rick Solomon. Version T1.0
-
- * ASSOCIATED FILES
- DECODE.PAS
- DECODE88.PAS
- DECODE.TXT
- ==========================================================================
- }
- {.PL65}
- {The following function (DECODE) converts REAL numbers stored
- by a BASIC program in a random access file (i.e. in ASCII
- format) and read by a Pascal program into a number which
- can be used by Pascal. BASIC stores a REAL (single precision)
- number as a four byte vector starting with the least
- significant byte in the first position to the most significant
- byte in third position with the exponent in fourth. TURBO
- Pascal uses a six byte format starting with the exponent in
- position 0 then least to most significant bytes in positions
- one through five respectively.
-
- The function takes advantage of TURBO's absolute addressing
- capabilities to declare a real number and a six byte array
- in the same six bytes of memory. Since BASIC and TURBO use
- similar encoding schemes, it is possible to read the four
- byte BASIC format and to place the individual byte values into
- the proper locations in the Pascal representation. The array
- is then read as a number which Pascal can understand.
-
- This function WILL NOT WORK with TURBO-87 or TURBOBCD which use
- eight or ten byte REALs respectively with different encoding
- schemes.
-
- A global TYPE SHORT_VECTOR = ARRAY[1..4] OF BYTE must be
- declared in the calling routine and used to pass the values
- to the function.}
-
-
- FUNCTION DECODE (BASIC_REAL : SHORT_VECTOR) : REAL;
-
- TYPE
- LONG_VECTOR = ARRAY[0..5] OF BYTE;
-
- VAR
- NUMBER : REAL;
- DECODER : LONG_VECTOR ABSOLUTE NUMBER;
-
- BEGIN
- DECODER[0] := BASIC_REAL[4];
- DECODER[1] := 0;
- DECODER[2] := 0;
- DECODER[3] := BASIC_REAL[1];
- DECODER[4] := BASIC_REAL[2];
- DECODER[5] := BASIC_REAL[3];
-
- DECODE := NUMBER;
-
- END; {FUNCTION DECODE}