Figure 33.
VIRTUAL_PRINTER body for COM2 port.
-----------------------------------------------------------
-- VPBCOM2.ada
-- 20 October 1987
-- Version 2.0
-- Do-While Jones
-- 324 Traci Lane
-- Ridgecrest, CA 93555
-- (619) 375-4607
-- This version works for Alsys & Meridian Ada on an IBM
-- with the printer connected to the COM2 serial output
-- port.
-- The printer connected to COM2 is an ancient Microline 83,
-- which seems to be a little slow to tell the PC that it
-- can't accept another character because it is printing a
-- line. Consequently, the first character of a line
-- sometimes gets lost. The solution is to send an ASCII.NUL
-- after every CR and LF. If the NUL gets lost, no harm is
-- done.
with TEXT_IO;
package body VIRTUAL_PRINTER is
PRINTER : TEXT_IO.File_type;
PRINTER_NAME : string(1..80);
LENGTH : natural;
procedure put(C : character) is
begin
TEXT_IO.put(PRINTER,C);
-- the following is required by the Microline 83 printer
if C = ASCII.CR or C = ASCII.LF then
TEXT_IO.put(PRINTER,ASCII.NUL);
end if;
end put;
procedure put(S : string) is
begin
for i in S'RANGE loop
put(S(i));
end loop;
end put;
procedure Set_Output(DEVICE : string) is
begin
TEXT_IO.Close(PRINTER);
TEXT_IO.Create(PRINTER,TEXT_IO.OUT_FILE,DEVICE);
LENGTH := DEVICE'LENGTH;
PRINTER_NAME(1..LENGTH) := DEVICE;
exception
when TEXT_IO.NAME_ERROR =>
raise NAME_ERROR;
when TEXT_IO.USE_ERROR =>
raise USE_ERROR;
end Set_Output;
function Current_Output return string is
begin
return PRINTER_NAME(1..LENGTH);
end Current_Output;
function Standard_Output return string is
begin
return "COM2";
end Standard_Output;
begin
TEXT_IO.Create(PRINTER,TEXT_IO.OUT_FILE,Standard_Output);
LENGTH := 4;
PRINTER_NAME(1..LENGTH) := Standard_Output;
end VIRTUAL_PRINTER;