HPlogo ALLBASE/SQL Advanced Application Programming Guide: HP 3000 MPE/iX Computer Systems > Chapter 12 Corrections to the BCDToString Example Program Routine

Correcting the Pascal Language Program

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

The one replacement page for program pasex10a in chapter 10 of the "ALLBASE/SQL Pascal Application Programming Guide" appears on the next page.

Figure 12-2 Program pasex10a: Dynamic Commands of Unknown Format

     Abort             : boolean; 

   $PAGE $

   (* Procedure BCDToString converts a decimal field in the "DataBuffer"

    * buffer to its decimal presentation.  Other input parameters are

    * the Length, precision and Scale.  The input decimal field is passed

    * via "DataBuffer" and the output String is passed via "result".

    *)

   procedure BCDToString (DataBuffer : BCDType; Length : SmallInt; 2 

                        Precision : SmallInt; Scale : SmallInt;

                        var Result : String);

   const

     hexd         = '0123456789ABCDEF';    (* Hexadecimal digits #001*)

     ASCIIZero = ord('0');

     PlusSign  = 12;

     MinusSign = 13;

     UnSigned  = 14;

   var

     i,

     DecimalPlace,

     PutPos,

     DataEnd,

     DataStart : Integer;

     done  : boolean;



   begin

     DataEnd := (Length*2) - 1;

     DataStart := (DataEnd - Precision) + 1;

     Result := StrRpt (' ',StrMax(Result));

     DecimalPlace := (Precision-Scale) -1;



   (* convert decimal to character String *)

     if DecimalPlace = 0 then

       begin



         Result[1] := '.';

         PutPos := 2;



       end

     else

       PutPos := 1;

       for i := DataStart to DataEnd do

       begin
Feedback to webmaster