program labeler;



uses

  Graph,

  Crt;



var

  InFile, OutFile:  string;



Procedure InitGraphics;

{***************************************************************************}

{*  Task:  This procedure switches from CRT mode text output to graphics.

{*    Your program must include the turbo unit Graph.

{*    The *.BGI (graphics driver) program must be available.

{*  Author:  C1C David W. Croft, CS-36, x4306

{***************************************************************************}

var

  GraphDriver: integer;

  GraphMode: integer;

  ErrorCode: integer;

begin

  DetectGraph(GraphDriver, GraphMode);

  InitGraph(GraphDriver, GraphMode, '');

  ErrorCode := GraphResult;

  if ErrorCode <> grOk then

    begin

      RestoreCrtMode;

      Writeln('Graphics error:  ',GraphErrorMsg(ErrorCode));

      Writeln('Program aborted...');

      Halt(1);

    end;

end;



procedure intro(var InFile, OutFile: string);

{***************************************************************************}

begin

  clrscr;

  writeln('This program takes FalcoNet distro lists and converts them into');

  writeln('ascii files spaced for printing out on labels for CQ distro.');

  writeln('The net distribution list must have been taken off the net and');

  writeln('stored on the personal computer''s disk.');

  writeln('Control-Break to quit.');

  writeln('C1C David W. Croft, class of 1990, CS-36, x4306');

  writeln;

  write('Name of distro list file:  ');

  readln(InFile);

  write('Name of ascii label file to be created:  ');

  readln(OutFile);

end;



procedure DoIt(Infile, OutFile: string);

{***************************************************************************}

var

  InF, OutF:  text;

  alpha: integer;

  Khar: char;

begin

  assign(InF, InFile);

  assign(OutF, OutFile);

  reset(InF);

  rewrite(OutF);

  repeat

    read(InF, Khar);

    if (Khar = #10) then

      MoveTo(2, GetY)

    else

      if (Khar = #13) then

        MoveTo(GetX, GetY+8)

      else

        OutText(Khar);

  until eof(InF);

  close(InF);

  close(OutF);

end;



Procedure PlaceCursor;

{***************************************************************************}

var

  BitMap:  byte;

  x1,y1,x2,y2: integer;

  p: pointer;

  alpha: integer;

  bravo: string;

begin

  x1 := 1;

  y1 := 1;

  x2 := 9;

  y2 := 9;

  BitMap := ImageSize(x1, y1, x2, y2);

  GetMem(p, BitMap);

  GetImage(x1,y1,x2,y2,p^);

  SetFillStyle(SolidFill,9);

  Bar(x1,y1,x2,y2);

  PutImage(x1, y1,p^,1);

end;



{***************************************************************************}

{***************************************************************************}

begin

  intro(InFile, OutFile);

  InitGraphics;

  SetPalette(2, White);

  SetBkColor(White);

  SetPalette(1, Black);

  SetColor(1);

  ClearDevice;

  SetTextStyle(DefaultFont, HorizDir, 1);

  MoveTo(2,2);

  DoIt(InFile, OutFile);

  PlaceCursor;

  MainLoop;

  readln;

  CloseGraph;

end.