{PRINTUSG.INC} PROCEDURE PrintUsing ( Mask : String80; Number : real; Out : char); {This procedure emulates the PRINT USING routine available in many versions of MicroSoft BASIC. Author: Bill Collins Application: CP/M-80, CP/M-86, MS-DOS, PC-DOS Enhanced by: L. L. Smith; 2827 Klusner Ave.; Parma, OH 44134 added ability to print to screen or list device depending on passed parameter.} const Comma : char = ','; Point : char = '.'; MinusSign : char = '-'; var FieldWidth, IntegerLength, I, J, Places, PointPosition : integer; UsingCommas, Decimal, Negative : boolean; OutString, IntegerString : String80; Begin Negative := Number < 0; Number := abs ( Number ); Places := 0; FieldWidth := length ( Mask ); UsingCommas := pos ( Comma, Mask ) > 0; Decimal := pos ( Point, Mask ) > 0; If Decimal then begin PointPosition := pos ( Point, Mask ); Places := FieldWidth - PointPosition; end; Str ( Number : 0 : Places, OutString ); If UsingCommas then begin J := 0; IntegerString := copy ( OutString, 1, length ( OutString ) - Places ); IntegerLength := length ( IntegerString ); If Decimal then IntegerLength := IntegerLength - 1; For I := IntegerLength downto 2 do begin J := J + 1; If J mod 3 = 0 then Insert ( Comma, OutString, I ) end end; If Negative then OutString := MinusSign + OutString; If UpCase(Out) = 'S' Then Write ( OutString : FieldWidth + 1 ) Else Write (Lst, OutString : FieldWidth + 1); End; (* PrintUsing *)