.CM  SCRIPT , Version - 1.1 , last edited by barbara
.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 2000-2004 SAP AG$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SQL$Project Distributed Database System$VIN35$
.tt 2 $$$
.tt 3 $$Integer-String-Conversions$$1998-05-07$
***********************************************************
.nf
 
.nf
 
 
    ========== licence begin  GPL
    Copyright (c) 2000-2004 SAP AG
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    ========== licence end
 
.fo
 
 
.fo
.nf
.sp
MODULE  : Binary_String_Conversions
=========
.sp
Purpose : Different number representations
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
              i35intlj_into_str (
                    source_num     : tsp00_Int4;
                    VAR result_str : tsp00_C10;
                    VAR res_len    : integer);
 
        PROCEDURE
              i35intrj_into_str (
                    source_num     : tsp00_Int4;
                    VAR result_str : tsp00_C10);
 
        FUNCTION
              i35ljstr_into_int (
                    VAR source_str : tsp00_C10;
                    source_len     : integer;
                    VAR overflow   : boolean) : tsp00_Int4;
 
        FUNCTION
              i35anystr_into_int (
                    VAR source_str : tsp00_Buf;
                    source_len     : integer;
                    VAR overflow   : boolean) : tsp00_Int4;
 
        PROCEDURE
              i35chr4 (
                    VAR line     : tsp00_MoveObj;
                    startpos     : integer;
                    endpos       : integer;
                    val          : tsp00_Int4;
                    VAR overflow : boolean);
 
        FUNCTION
              i35ord4 (
                    VAR line  : tsp00_MoveObj;
                    startpos  : integer;
                    endpos    : integer) : tsp00_Int4;
 
        PROCEDURE
              i35chr2unsigned (
                    source_swap  : tsp00_SwapKind;
                    val          : tsp00_Int4;
                    VAR line     : tsp00_MoveObj;
                    startpos     : integer;
                    VAR overflow : boolean);
 
        PROCEDURE
              i35ord2unsigned (
                    dest_swap : tsp00_SwapKind;
                    VAR line  : tsp00_MoveObj;
                    startpos  : integer;
                    VAR val   : tsp00_Int4);
 
        PROCEDURE
              i35chr2swap (
                    VAR line    : tsp00_MoveObj;
                    startpos    : integer;
                    val         : tsp00_Int2;
                    source_swap : tsp00_SwapKind;
                    dest_swap   : tsp00_SwapKind);
 
        PROCEDURE
              i35ord2swap (
                    VAR line    : tsp00_MoveObj;
                    startpos    : integer;
                    VAR val     : tsp00_Int2;
                    source_swap : tsp00_SwapKind;
                    dest_swap   : tsp00_SwapKind);
 
        PROCEDURE
              i35ord4swap (
                    VAR line    : tsp00_MoveObj;
                    startpos    : integer;
                    VAR val     : tsp00_Int4;
                    source_swap : tsp00_SwapKind;
                    dest_swap   : tsp00_SwapKind);
 
        PROCEDURE
              i35i2swap (
                    VAR i2      : tsp_int_map_c2;
                    source_swap : tsp00_SwapKind;
                    dest_swap   : tsp00_SwapKind);
 
        PROCEDURE
              i35c2swap (
                    VAR buf     : tsp00_Buf;
                    startpos    : integer;
                    source_swap : tsp00_SwapKind;
                    dest_swap   : tsp00_SwapKind);
 
        PROCEDURE
              i35c4swap (
                    VAR buf      : tsp00_Buf;
                    startpos     : integer;
                    source_swap  : tsp00_SwapKind;
                    dest_swap    : tsp00_SwapKind);
 
        PROCEDURE
              i35gsrel (
                    VAR buf      : tsp00_Buf;
                    startpos     : integer;
                    VAR sreal    : tsp00_Shortreal);
 
        PROCEDURE
              i35psrel (
                    VAR sreal    : tsp00_Shortreal;
                    VAR buf      : tsp00_Buf;
                    startpos     : integer);
 
        PROCEDURE
              i35glrel (
                    VAR buf      : tsp00_Buf;
                    startpos     : integer;
                    VAR lreal    : tsp00_Longreal);
 
        PROCEDURE
              i35plrel (
                    VAR lreal    : tsp00_Longreal;
                    VAR buf      : tsp00_Buf;
                    startpos     : integer);
 
        FUNCTION
              in3530 : tsp00_Int4;
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              Kernel_move_and_fill : VGG101;
 
        PROCEDURE
              SAPDB_PascalForcedFill (
                    size        : tsp00_Int4;
                    m           : tsp00_MoveObjPtr;
                    pos         : tsp00_Int4;
                    len         : tsp00_Int4;
                    fillchar    : char);
 
        PROCEDURE
              SAPDB_PascalForcedMove (
                    source_upb  : tsp00_Int4;
                    destin_upb  : tsp00_Int4;
                    source      : tsp00_MoveObjPtr;
                    source_pos  : tsp00_Int4;
                    destin      : tsp00_MoveObjPtr;
                    destin_pos  : tsp00_Int4;
                    length      : tsp00_Int4);
 
        PROCEDURE
              s10mv (
                    source_upb  : tsp00_Int4;       
                    destin_upb  : tsp00_Int4;
                    source      : tsp00_MoveObjPtr;    
                    source_pos  : tsp00_Int4;
                    destin      : tsp00_MoveObjPtr;    
                    destin_pos  : tsp00_Int4;
                    length      : tsp00_Int4);
 
      ------------------------------ 
 
        FROM
              RTE-Extension-20 : VSP20;
 
        FUNCTION
              s20or4a (
                    VAR source : tsp00_C4;
                    source_pos : tsp00_Int4) : tsp00_Int4;
 
        PROCEDURE
              s20ch4 (
                    val : tsp00_Int4; VAR dest : tsp00_MoveObj; di : tsp00_Int4);
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              s20or4a;
 
              tsp00_MoveObj tsp00_C4
 
        PROCEDURE
              s20ch4;
 
              tsp00_MoveObj tsp00_MoveObj
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  :
.sp
.cp 3
Created : 1990-09-06
.sp
.cp 3
.sp
.cp 3
Release :      Date : 1998-05-07
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
.sp;.nf
PROCEDURE
      i35intlj_into_str (source_num : int4;
            VAR result_str : c10;
            VAR res_len    : integer);
.sp;.fo
SOURCE_NUM must be greater or equal 0.
The string representation of the source integer is returned
in RESULT_STR, left-justified and with length RES_LEN.
The positions res_len + 1 to 10 contain blanks.
.sp 2;.nf
PROCEDURE
      i35intrj_into_str (source_num : int4;
            VAR result_str : c10);
.sp;.fo
SOURCE_NUM must be greater or equal 0.
The string representation of the source integer is returned
right-justified in RESULT_STR. If leading positions are not used,
they contain blanks.
.sp 2;.nf
FUNCTION
      i35ljstr_into_int (VAR source_str : c10;
            source_len   : integer;
            VAR overflow : boolean) : int4;
.sp;.fo
SOURCE_STR is assumed to contain only digits.
The content of SOURCE_STR from position 1 to SOURCE_LEN is converted
into an integer. Internally a real variable is used, therefore
no Pascal overflow occurs, even if the result doesn't
meet the int4 limits. If the result is greater maxint4, the
function value is maxint4 and OVERFLOW is set to true.
.sp 2;.nf
FUNCTION
      i35anystr_into_int (
            VAR source_str : tsp00_Buf;
            source_len     : integer;
            VAR overflow   : boolean) : tsp00_Int4;
.sp;.fo
SOURCE_STR can contain leading and trailing blanks. The characters
in between must be digits (no examination!), the first may be a
sign instead.
The numeric string thus found is converted as described for
i35ljstr_into_int, finally the sign is applied.
.sp 2;.nf
PROCEDURE
      i35chr4 (VAR line  : moveobject;
            startpos     : integer;
            endpos       : integer;
            val          : int4;
            VAR overflow : boolean);
.sp;.fo
The function converts the integer VAL into
1, 2 or 4 characters (depending on STARTPOS and ENDPOS) of LINE.
If VAL doesn't match the limits of the corresponding signed integer
(e.g. ENDPOS = STARTPOS, VAL > max_int1), the positions in
LINE will contain '*' characters.
If ENDPOS - STARTPOS + 1 is neither 1 nor 2 nor 4, a case label
checking error will occur.
.sp 2;.nf
FUNCTION
      i35ord4 (VAR line : moveobject;
            startpos  : integer;
            endpos    : integer) : int4;
.sp;.fo
The function converts 1, 2 or 4 characters (depending on STARTPOS
and ENDPOS) of the moveobject LINE into a signed integer.
If ENDPOS - STARTPOS + 1 is neither 1 nor 2 nor 4, a case label
checking error will occur.
.sp 2;.nf
PROCEDURE
      i35chr2swap (VAR line : moveobject;
            startpos    : integer;
            val         : int2;
            source_swap : swap_kind;
            dest_swap   : swap_kind);
.sp;.fo
The procedure converts the int2 VAL into 2 characters
(positions STARTPOS and STARTPOS + 1) of the moveobject LINE.
If necessary, swapping from SOURCE_SWAP-kind to DEST_SWAP-kind
is done.
.sp 2;.nf
PROCEDURE
      i35ord2swap (VAR line : moveobject;
            startpos    : integer;
            VAR val     : int2;
            source_swap : swap_kind;
            dest_swap   : swap_kind);
.sp;.fo
The procedure converts the two characters at
position STARTPOS and STARTPOS + 1 of the moveobject LINE
into the int2 VAL.
If necessary, swapping from SOURCE_SWAP-kind to DEST_SWAP-kind
is done.
.sp 2;.nf
PROCEDURE
      i35i2swap (VAR i2 : int_map_c2;
            source_swap : swap_kind;
            dest_swap   : swap_kind);
.sp;.fo
The integer I2.MAP_INT is swapped according to SOURCE_SWAP
and DEST_SWAP.
.sp 2;.nf
PROCEDURE
      i35c2swap (VAR buf : buffer;
            startpos    : integer;
            source_swap : swap_kind;
            dest_swap   : swap_kind);
.sp;.fo
The procedure swaps the int2 represented by the characters
at position STARTPOS and STARTPOS + 1 of the buffer BUF
according to SOURCE_SWAP and DEST_SWAP.
.sp 2;.nf
PROCEDURE
      i35c4swap (VAR buf : buffer;
            startpos     : integer;
            source_swap  : swap_kind;
            dest_swap    : swap_kind);
.sp;.fo
The procedure swaps the int4 represented by the characters
at position STARTPOS through STARTPOS + 3 of the buffer BUF
according to SOURCE_SWAP and DEST_SWAP.
 
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
 
 
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
 
 
CONST
      complement     =  256;
      min_int1       = -128;
      max_int1       =  127;
      min_int2       = -32768;
      max_int2       =  32767;
 
TYPE
 
      real_map_c4 = RECORD
            CASE boolean OF
                true :
                    (map_real : tsp00_Shortreal);
                false :
                    (map_c4   : tsp00_C4);
                END;
            (*ENDCASE*) 
 
 
      real_map_c8 = RECORD
            CASE boolean OF
                true :
                    (map_real : tsp00_Longreal);
                false :
                    (map_c8   : tsp00_C8);
                END;
            (*ENDCASE*) 
 
 
 
(*------------------------------*) 
 
FUNCTION
      in3530 : tsp00_Int4;
 
BEGIN
(* linkcheck function *)
in3530 := 219020325;
END;
 
(*------------------------------*) 
 
PROCEDURE
      i35intlj_into_str (
            source_num     : tsp00_Int4;
            VAR result_str : tsp00_C10;
            VAR res_len    : integer);
 
VAR
      temp : tsp00_C10;
      i    : integer;
 
BEGIN
IF  source_num >= 0
THEN
    BEGIN
    result_str := '          ';
    i := 10;
    REPEAT
        temp  [i]  := chr (ord ('0') + source_num MOD 10);
        i := i - 1;
        source_num := source_num DIV 10;
    UNTIL
        (source_num = 0) OR (i = 0);
    (*ENDREPEAT*) 
    res_len := 10 - i;
    FOR i := 1 TO res_len DO
        result_str  [i]  := temp [ i + 10 - res_len] ;
    (*ENDFOR*) 
    END
ELSE
    BEGIN
    SAPDB_PascalForcedFill (10, @result_str, 1, 10, '*');
    res_len := 10;
    END;
(*ENDIF*) 
END; (* i35intlj_into_str *)
 
(*------------------------------*) 
 
PROCEDURE
      i35intrj_into_str (
            source_num     : tsp00_Int4;
            VAR result_str : tsp00_C10);
 
VAR
      i : integer;
 
BEGIN
IF  source_num >= 0
THEN
    BEGIN
    result_str := '          ';
    i := 10;
    REPEAT
        result_str  [i]  := chr (ord ('0') + source_num MOD 10);
        i := i - 1;
        source_num := source_num DIV 10;
    UNTIL
        (source_num = 0) OR (i = 0);
    (*ENDREPEAT*) 
    END
ELSE
    SAPDB_PascalForcedFill (10, @result_str, 1, 10, '*');
(*ENDIF*) 
END; (* i35intrj_into_str *)
 
(*------------------------------*) 
 
FUNCTION
      i35ljstr_into_int (
            VAR source_str : tsp00_C10;
            source_len     : integer;
            VAR overflow   : boolean) : tsp00_Int4;
 
VAR
      i      : integer;
      digit  : integer;
      number : real;
 
BEGIN
overflow := false;
number := 0.0;
IF  source_len > 10
THEN
    source_len := 10;
(*ENDIF*) 
FOR i := 1 TO source_len DO
    BEGIN
    digit := ord (source_str  [i] ) - ord ('0');
    number := number * 10 + digit;
    END;
(*ENDFOR*) 
IF  number > csp_maxint4
THEN
    BEGIN
    i35ljstr_into_int := csp_maxint4;
    overflow := true;
    END
ELSE
    i35ljstr_into_int := round (number);
(*ENDIF*) 
END; (* i35ljstr_into_int *)
 
(*------------------------------*) 
 
FUNCTION
      i35anystr_into_int (
            VAR source_str : tsp00_Buf;
            source_len     : integer;
            VAR overflow   : boolean) : tsp00_Int4;
 
TYPE
      sign_type = (not_found, no_sign, plus_sign, minus_sign);
 
VAR
      sign    : sign_type;
      i       : integer;
      start   : integer;
      digit   : integer;
      number  : real;
      result  : tsp00_Int4;
 
BEGIN
overflow := false;
number := 0.0;
IF  source_len > sizeof (source_str)
THEN
    source_len := sizeof (source_str);
(*ENDIF*) 
start := 1;
sign := not_found;
REPEAT
    CASE source_str [start] OF
        bsp_c1 :
            start := start + 1;
        '-' :
            sign := minus_sign;
        '+' :
            sign := plus_sign;
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' :
            sign := no_sign;
        OTHERWISE
            start := source_len + 1;
        END;
    (*ENDCASE*) 
UNTIL
    (start > source_len) OR (sign <> not_found);
(*ENDREPEAT*) 
IF  (sign = minus_sign) OR (sign = plus_sign)
THEN
    start := start + 1;
(*ENDIF*) 
FOR i := start TO source_len DO
    IF  source_str [i] in ['0'..'9']
    THEN
        BEGIN
        digit := ord (source_str [i] ) - ord ('0');
        number := number * 10 + digit;
        END;
    (*ENDIF*) 
(*ENDFOR*) 
IF  number > csp_maxint4
THEN
    BEGIN
    result := csp_maxint4;
    overflow := true;
    END
ELSE
    result := round (number);
(*ENDIF*) 
IF  sign = minus_sign
THEN
    i35anystr_into_int := - result
ELSE
    i35anystr_into_int := result;
(*ENDIF*) 
END; (* i35anystr_into_int *)
 
(*------------------------------*) 
 
PROCEDURE
      i35chr4 (
            VAR line     : tsp00_MoveObj;
            startpos     : integer;
            endpos       : integer;
            val          : tsp00_Int4;
            VAR overflow : boolean);
 
VAR
      val2 : tsp_int_map_c2;
 
BEGIN
overflow := false;
CASE (endpos - startpos + 1) OF
    1 :
        IF  (val >= min_int1) AND (val < 0)
        THEN
            line [ startpos ] := chr (complement + val)
        ELSE
            IF  (val >= 0) AND (val <= max_int1)
            THEN
                line [ startpos ] := chr (val)
            ELSE
                BEGIN
                overflow := true;
                line [ startpos ] := '*';
                END;
            (*ENDIF*) 
        (*ENDIF*) 
    2 :
        IF  (val < min_int2) OR (val > max_int2)
        THEN
            BEGIN
            overflow := true;
            line [ startpos ] := '*';
            line [ endpos ] := '*';
            END
        ELSE
            BEGIN
            val2.map_int := val;
            line [ startpos ] := val2.map_c2  [1] ;
            line [ endpos ] := val2.map_c2  [2] ;
            END;
        (*ENDIF*) 
    4 :
        s20ch4 (val, line, startpos);
    END;
(*ENDCASE*) 
END; (* i35chr4 *)
 
(*------------------------------*) 
 
FUNCTION
      i35ord4 (
            VAR line  : tsp00_MoveObj;
            startpos  : integer;
            endpos    : integer) : tsp00_Int4;
 
VAR
      val2  : tsp_int_map_c2;
      carry : tsp00_C4;
      i     : integer;
 
BEGIN
CASE (endpos - startpos + 1) OF
    1 :
        IF  ord (line [ startpos] ) > max_int1
        THEN
            i35ord4 := ord (line [ startpos] ) - complement
        ELSE
            i35ord4 := ord (line [ startpos] );
        (*ENDIF*) 
    2 :
        BEGIN
        val2.map_c2  [1]  := line [ startpos] ;
        val2.map_c2  [2]  := line [ endpos] ;
        i35ord4 := val2.map_int;
        END;
    4 :
        BEGIN
        FOR i := 1 TO 4 DO
            carry [i]  := line [ startpos + i - 1] ;
        (*ENDFOR*) 
        i35ord4 := s20or4a (carry, 1);
        END;
    END;
(*ENDCASE*) 
END; (* i35ord4 *)
 
(* ================================================================== *)
(* i35chr2unsigned : source_swap    e.g. i01g^.i20.swap               *)
(*                   write value > INT2_MXSP00 and < 65535 as two chars *)
(* ================================================================== *)
(*------------------------------*) 
 
PROCEDURE
      i35chr2unsigned (
            source_swap  : tsp00_SwapKind;
            val          : tsp00_Int4;
            VAR line     : tsp00_MoveObj;
            startpos     : integer;
            VAR overflow : boolean);
 
VAR
      hi1, lo1, hi2, lo2 : integer;
 
BEGIN
overflow := false;
IF  val > 65535 (* 15*4096 + 15*256 + 15*16 + 15*1 *)
THEN
    BEGIN
    overflow := true;
    line [ startpos     ] := '*';
    line [ startpos + 1 ] := '*';
    END
ELSE
    BEGIN
    hi1 := val DIV 4096;
    val := val - (hi1 * 4096);
    lo1 := val DIV 256;
    val := val - (lo1 * 256);
    hi2 := val DIV 16;
    val := val - (hi2 * 16);
    lo2 := val;
    IF  source_swap = sw_normal
    THEN
        BEGIN
        line [ startpos     ] := chr ( hi1 * 16 + lo1 );
        line [ startpos + 1 ] := chr ( hi2 * 16 + lo2 );
        END
    ELSE
        BEGIN
        line [ startpos + 1 ] := chr ( hi1 * 16 + lo1 );
        line [ startpos     ] := chr ( hi2 * 16 + lo2 );
        END;
    (*ENDIF*) 
    END;
(*ENDIF*) 
END; (* i35chr2unsigned *)
 
(* =============================================================== *)
(* i35ord2unsigned : dest_swap      e.g. i01g^.i20.swap            *)
(*                   read two bytes from line starting at startpos *)
(*                   give integer even if > INT2_MXSP00              *)
(* =============================================================== *)
(*------------------------------*) 
 
PROCEDURE
      i35ord2unsigned (
            dest_swap : tsp00_SwapKind;
            VAR line  : tsp00_MoveObj;
            startpos  : integer;
            VAR val   : tsp00_Int4);
 
BEGIN
IF  dest_swap = sw_normal
THEN
    val := (256 * ord (line [startpos])) + (ord (line [startpos + 1]))
ELSE
    val := (256 * ord (line [startpos + 1])) + (ord (line [startpos]));
(*ENDIF*) 
END; (* i35ord2unsigned *)
 
(*------------------------------*) 
 
PROCEDURE
      i35chr2swap (
            VAR line    : tsp00_MoveObj;
            startpos    : integer;
            val         : tsp00_Int2;
            source_swap : tsp00_SwapKind;
            dest_swap   : tsp00_SwapKind);
 
VAR
      val2 : tsp_int_map_c2;
 
BEGIN
val2.map_int := val;
IF  (source_swap = dest_swap) OR
    ( (source_swap <> sw_normal) AND (dest_swap <> sw_normal) )
THEN
    BEGIN
    line [ startpos ] := val2.map_c2  [1] ;
    line [ startpos + 1 ] := val2.map_c2  [2] ;
    END
ELSE
    BEGIN
    line [ startpos ] := val2.map_c2  [2] ;
    line [ startpos + 1 ] := val2.map_c2  [1] ;
    END;
(*ENDIF*) 
END; (* i35chr2swap *)
 
(*------------------------------*) 
 
PROCEDURE
      i35ord2swap (
            VAR line    : tsp00_MoveObj;
            startpos    : integer;
            VAR val     : tsp00_Int2;
            source_swap : tsp00_SwapKind;
            dest_swap   : tsp00_SwapKind);
 
VAR
      val2 : tsp_int_map_c2;
 
BEGIN
IF  (source_swap = dest_swap) OR
    ( (source_swap <> sw_normal) AND (dest_swap <> sw_normal) )
THEN
    BEGIN
    val2.map_c2  [1]  := line [ startpos] ;
    val2.map_c2  [2]  := line [ startpos + 1] ;
    END
ELSE
    BEGIN
    val2.map_c2  [2]  := line [ startpos] ;
    val2.map_c2  [1]  := line [ startpos + 1] ;
    END;
(*ENDIF*) 
val := val2.map_int;
END; (* i35ord2swap *)
 
(*------------------------------*) 
 
PROCEDURE
      i35ord4swap (
            VAR line    : tsp00_MoveObj;
            startpos    : integer;
            VAR val     : tsp00_Int4;
            source_swap : tsp00_SwapKind;
            dest_swap   : tsp00_SwapKind);
 
VAR
      carry : tsp00_C4;
      i     : integer;
 
BEGIN
IF  source_swap = dest_swap
THEN
    FOR i := 1 TO 4 DO
        carry [i]  := line [ startpos + i - 1]
    (*ENDFOR*) 
ELSE
    FOR i := 1 TO 4 DO
        carry [ i ] := line [ startpos + 4 - i] ;
    (*ENDFOR*) 
(*ENDIF*) 
val := s20or4a (carry, 1);
END; (* i35ord4swap *)
 
(*------------------------------*) 
 
PROCEDURE
      i35i2swap (
            VAR i2      : tsp_int_map_c2;
            source_swap : tsp00_SwapKind;
            dest_swap   : tsp00_SwapKind);
 
VAR
      carry : char;
 
BEGIN
IF  ((source_swap = sw_normal) AND (dest_swap <> sw_normal))
    OR ((source_swap <> sw_normal) AND (dest_swap = sw_normal))
THEN
    BEGIN
    carry := i2.map_c2  [1] ;
    i2.map_c2  [1]  := i2.map_c2  [2] ;
    i2.map_c2  [2]  := carry;
    END;
(*ENDIF*) 
END; (* i35i2swap *)
 
(*------------------------------*) 
 
PROCEDURE
      i35c2swap (
            VAR buf     : tsp00_Buf;
            startpos    : integer;
            source_swap : tsp00_SwapKind;
            dest_swap   : tsp00_SwapKind);
 
VAR
      carry : char;
 
BEGIN
IF  ((source_swap = sw_normal) AND (dest_swap <> sw_normal))
    OR ((source_swap <> sw_normal) AND (dest_swap = sw_normal))
THEN
    BEGIN
    carry := buf [ startpos] ;
    buf [ startpos ] := buf [ startpos + 1] ;
    buf [ startpos + 1 ] := carry;
    END;
(*ENDIF*) 
END; (* i35c2swap *)
 
(*------------------------------*) 
 
PROCEDURE
      i35c4swap (
            VAR buf      : tsp00_Buf;
            startpos     : integer;
            source_swap  : tsp00_SwapKind;
            dest_swap    : tsp00_SwapKind);
 
VAR
      carry : tsp00_C4;
      i     : integer;
 
BEGIN
FOR i := 1 TO 4 DO
    carry  [i]  := buf [ startpos + i - 1] ;
(*ENDFOR*) 
IF  ((source_swap = sw_normal) AND (dest_swap = sw_full_swapped)) OR
    ((dest_swap = sw_normal) AND (source_swap = sw_full_swapped))
THEN
    FOR i := 0 TO 3 DO
        buf [ startpos + i ] := carry [ 4 - i] ;
    (*ENDFOR*) 
(*ENDIF*) 
IF  ((source_swap = sw_normal) AND (dest_swap = sw_part_swapped)) OR
    ((dest_swap = sw_normal) AND (source_swap = sw_part_swapped))
THEN
    BEGIN
    buf [ startpos ] := carry  [2] ;
    buf [ startpos + 1 ] := carry  [1] ;
    buf [ startpos + 2 ] := carry  [4] ;
    buf [ startpos + 3 ] := carry  [3] ;
    END;
(*ENDIF*) 
IF  ((source_swap = sw_full_swapped) AND (dest_swap = sw_part_swapped))
    OR
    ((dest_swap = sw_full_swapped) AND (source_swap = sw_part_swapped))
THEN
    BEGIN
    buf [ startpos ] := carry  [3] ;
    buf [ startpos + 1 ] := carry  [4] ;
    buf [ startpos + 2 ] := carry  [1] ;
    buf [ startpos + 3 ] := carry  [2] ;
    END;
(*ENDIF*) 
END; (* i35c4swap *)
 
(*------------------------------*) 
 
PROCEDURE
      i35gsrel (
            VAR buf   : tsp00_Buf;
            startpos  : integer;
            VAR sreal : tsp00_Shortreal);
 
VAR
      trans  : real_map_c4;
      i      : integer;
 
BEGIN
FOR i := 1 TO 4 DO
    trans.map_c4  [i]  := buf [ startpos + i - 1] ;
(*ENDFOR*) 
sreal := trans.map_real;
END; (* i35gsrel *)
 
(*------------------------------*) 
 
PROCEDURE
      i35psrel (
            VAR sreal    : tsp00_Shortreal;
            VAR buf      : tsp00_Buf;
            startpos     : integer);
 
VAR
      trans  : real_map_c4;
      i      : integer;
 
BEGIN
trans.map_real := sreal;
FOR i := 1 TO 4 DO
    buf [ startpos + i - 1 ] := trans.map_c4  [i] ;
(*ENDFOR*) 
END; (* i35psrel *)
 
(*------------------------------*) 
 
PROCEDURE
      i35glrel (
            VAR buf   : tsp00_Buf;
            startpos  : integer;
            VAR lreal : tsp00_Longreal);
 
VAR
      trans  : real_map_c8;
      i      : integer;
 
BEGIN
FOR i := 1 TO 8 DO
    trans.map_c8  [i]  := buf [ startpos + i - 1] ;
(*ENDFOR*) 
lreal := trans.map_real;
END; (* i35glrel *)
 
(*------------------------------*) 
 
PROCEDURE
      i35plrel (
            VAR lreal    : tsp00_Longreal;
            VAR buf      : tsp00_Buf;
            startpos     : integer);
 
VAR
      trans  : real_map_c8;
      i      : integer;
 
BEGIN
trans.map_real := lreal;
FOR i := 1 TO 8 DO
    buf [ startpos + i - 1 ] := trans.map_c8  [i] ;
(*ENDFOR*) 
END; (* i35plrel *)
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
.PA 
