
{Gnawbone Software - Written}
{and donated by Steve Baute }


{******************************************************}
{*                 Program GNAW*WORK                  *}
{*                      5/12/84                       *}
{*               Last  Revision:  12/14/84            *}
{*                                                    *}
{*         A program to configure a Gemini            *}
{*         printer and print text files.              *}
{*                                                    *}
{*        Please send comments and/or fixes           *}
{*        regarding this program to:                  *}
{*                                                    *}
{*                 GNAWBONE SOFTWARE                  *}
{*                 5814 W. 30TH ST.                   *}
{*                 INDIANAPOLIS, IN  46224            *}
{*                                                    *}
{*                 or to Compuserve ID#               *}
{*                     74106,770                      *}
{*                                                    *}
{*                                                    *}
{******************************************************}

Program GnawWork;
var
  Mode:  Char;

Procedure Beep; {Rings console bell}
  Begin;
    write(Con,#7); {This is the character code to ring bell}
  End; {Procedure Beep}


Procedure VerticalTabs;  {Sets standard top and bottom margins}
  Begin;
    writeln(Lst,#27#82#6); {Sets the top of form to the 6th line down}
    writeln(Lst,#27#78#9); {Sets skipvoer function to 9th line from the bottom}
  End; {Procedure VerticalTabs}


Procedure Data; {Writes screen logo text inside logo box}
  Begin;
    gotoxy(32,3);
      write('G N A W B O N E');
    gotoxy(38,4);
      write('1984');
    gotoxy(25,5);
      write('"Software for the marrow-minded"'); {Witty, don't you think!}
  End;{Procedure Data}


Procedure Box(StartColumn,StartRow,Height,Width,VerChar: Integer);
var
  Column,Row,
  UpLeftCor,UpRightCor,LowLeftCor,LowRightCor,HorChar:  Integer;

  Procedure SetChar;
    Begin;
      if VerChar=179 then
        begin;
          LowLeftCor:=192;
          LowRightCor:=217;
          UpLeftCor:=218;
          UpRightCor:=191;
          HorChar:=196;
        end
      else
        begin;
          LowLeftCor:=200;
          LowRightCor:=188;
          UpLeftCor:=201;
          UpRightCor:=187;
          HorChar:=205;
        end;
    End;{Procedure SetChar}


  Procedure HorizontalLine; {Forms horizontal lines for logo box}
    var
      MyLine:  String[80];
      Rush:  Char;
    Begin;
      MyLine:='';
      Rush:=Chr(HorChar);
      for Column:=StartColumn+1 to (StartColumn+Width)-1 do
        begin;
          MyLine:=MyLine + Rush; {Double horizontal line character}
        end;
      gotoxy(StartColumn+1,Row);
        write(MyLine);
    End;{Procedure HorizontalLine}


  Procedure TopLine;
    Begin;
      Row:=StartRow;
      gotoxy(StartColumn,Row);
        write(Chr(UpLeftCor));
      HorizontalLine;
      write(Chr(UpRightCor));
    End;{Procedure TopLine}


  Procedure BottomLine;
    Begin;
      Row:=StartRow+Height;
      gotoxy(StartColumn,Row);
        write(Chr(LowLeftCor));
      HorizontalLine;
      write(Chr(LowRightCor));
    End;{Procedure BottomLine}


  Procedure SideLine;
    Begin;
        for Row:=StartRow+1 to (StartRow+Height)-1 do
          begin;
            gotoxy(Column,Row);
              write(Chr(VerChar));
          end;
    End;{Procedure SideLine}


  Procedure LeftSide;
    Begin;
      Column:=StartColumn;
      SideLine;
    End;{Procedure Leftside}

  Procedure RightSide;
    Begin;
      Column:=StartColumn+Width;
      SideLine;
    End;{RightSide}


  Begin;{Procedure Box}
    SetChar;
    TopLine;
    RightSide;
    BottomLine;
    LeftSide;
  End;{Procedure Box}


Procedure SubFrame;
  Begin;{Procedure SubFrame}
    Box(26,11,10,27,179);
  End;{Procedure SubFrame}


Procedure Logo;
  Begin{Procedure Logo}
    Box(20,2,4,40,186);
    Data;
  End;{Procedure Logo}


Procedure Instructions; {Gives setup prompts and waits for responses}
  var
    KeyEnter:    Char;

  Begin;
    gotoxy(27,11);
      write('Printer SETUP Program');
    gotoxy(24,24);
      write('(Press any key to continue)');
    gotoxy(26,15);
      write('I N S T R U C T I O N S');
    gotoxy(26,17);
      write('1. Turn printer "off".  ');
        Beep;
          read(Kbd,KeyEnter); {"When Ready" Input}
    gotoxy(26,18);
      write('2. Position paper/printhead');
    gotoxy(29,19);
      write('to LINE 1, COLUMN 1. ');
        Beep;
          read(Kbd,KeyEnter); {"When Ready" Input}
    gotoxy(26,20);
      write('3. Turn Printer "on".  ');
        Beep;
          read(Kbd,KeyEnter); {"When Ready" Input}
    gotoxy(23,24);
      ClrEol;
    gotoxy(22,24);
      write('(P)ica, (E)lite or (C)ondensed Mode?  ');
        Beep;
  End; {Procedure Instructions}


Procedure Condensed; {Configures printer to Condensed print mode specs}
  Begin;
    writeln(Lst,#15); {Sets Condensed Typeface}
    VerticalTabs;
    write(Lst,#27#77#17); {Sets left margin at 17}
    writeln(Lst,#27#81#119);{Sets right margin at 119}
    writeln(Lst,#27#68#24#32#40#48#56#64#72#80#88#96#104#112#0);{Sets Tabs }
    ClrScr;
    writeln(Lst,#7); {Rings Bell}
    Logo;
    gotoxy(23,12);
      writeln('Printer set in CONDENSED mode');
  End; {Procedure Condensed}


Procedure Elite; {Configures printer to Elite print mode specs}
  Begin;
    writeln(Lst,#27#66#2);  {Sets Elite Typeface}
    VerticalTabs;
    writeln(Lst,#27#77#12); {Sets the left margin at 12}
    writeln(Lst,#27#81#96); {Sets the right margin at 96}
    writeln(Lst,#27#68#16#24#32#40#48#56#64#72#0);{Sets Tab positions 16...72}
    ClrScr;
    writeln(Lst,#7); {Rings printer bell}
    Logo;
    gotoxy(23,12);
      writeln('Printer set in ELITE Mode');
  End; {Procedure Elite}


Procedure Pica; {Configures printer to Pica print mode specs}
  Begin;
    writeln(Lst,#27#66#1);  {Sets Pica Typeface}
    VerticalTabs;
    writeln(Lst,#27#77#10); {Sets the left margin at 10}
    writeln(Lst,#27#81#75); {Sets the right margin at 75}
    writeln(Lst,#27#68#18#26#34#42#50#58#64#0);{Sets Tab positions 18...68}
    ClrScr;
    writeln(Lst,#7); {Rings printer bell}
    Logo;
    gotoxy(23,12);
      writeln('Printer set in PICA Mode');
  End; {Procedure Pica}


Procedure Italics; {Gives option of regular or italic typeface}
  Begin;
    gotoxy(21,18);
    write('(R)egular or (I)talic typeface? ');
    Beep;
    read(Kbd,Mode);
    write(Mode);
      if Mode='I' then
        writeln(Lst,#27#52)
      else
        if Mode='i' then
          writeln(Lst,#27#52);
  End; {Procedure Italics}


Procedure Configure; {Main configuration section}
  Begin;
    ClrScr;
    Logo;
    Instructions;
    read(kbd,Mode);
    write(Mode);
      case Mode of
        'C':Condensed;
        'c':Condensed;
        'E':Elite;
        'e':Elite;
        'P':Pica;
        'p':Pica;
      else
        Instructions;
      end;
    Italics;
  End;  {Procedure Configure}


Procedure Correct;
  Begin;
    ClrScr;
    gotoxy(32,12);
      write('File not found. ');
  End; {Procedure Correct}


Procedure Print;
  var
    FilVar:              Text;
    Line,
    Extraline:     string[255];
    I:              Integer;
    UnderLine,OK:      Boolean;
    FileName:       string[14];

  begin
    UnderLine:=false;
    ClrScr;
    Logo;
    gotoxy(22,17);
      write('Enter name of file to print:  ');
    Beep;
    readln(FileName);
    assign(FilVar,FileName);
    {$I-} Reset(FilVar){$I+};
    OK:=(IOresult=0);
    if OK then
      begin;
        gotoxy(22,17);
         ClrEol;
         write('Now printing "',FileName,'" file.');
         while not Eof(FilVar) do
           begin
             readln(FilVar,Line);
             I:= 1;ExtraLine := '';
             for I := 1 to Length(Line) do
               begin
                 if Line[I]<>^S then
                   begin
                     write(Lst,Line[I]);
                     if UnderLine then ExtraLine := ExtraLine+'_'
                     else ExtraLine := ExtraLine+' ';
                   end
                 else UnderLine := not UnderLine;
               end;
             write(Lst,^M);Writeln(Lst,ExtraLine);
           end; {while not Eof}
         writeln(Lst,#7);
         writeln(Lst,#12);
       end
     else
       begin
         gotoxy(22,17);
         ClrEol;
         write('File "',FileName,'" not found.');
         gotoxy(25,22);
           write('(Press any key to cont.) ');
           read(Kbd,Mode);
       end;
  End;{Procedure Print}


Procedure Choice; {Gives option of setting up printer}
  var YesNo:       Char;

  Begin
    ClrScr;
    Logo;
    gotoxy(24,12);
      write('Configure Printer? (Y or N) ');
      Beep;
      read(Kbd,YesNo);
        case YesNo of
          'Y':Configure;
          'y':Configure;
        end;
    ClrScr;
  End; {Procedure Choice}

Procedure Choose; {Gives option of printing a file}
  var YesNo:       Char;

  Begin
    ClrScr;
    Logo;
    gotoxy(24,12);
      write('Print a file? (Y or N) ');
      Beep;
      read(Kbd,YesNo);
        case YesNo of
          'Y':Print;
          'y':Print;
        end;
    ClrScr;
  End;{Procedure Choose}


Procedure Menu; {Main program menu}
  Begin;
    ClrScr;
    Logo;
    SubFrame;
    gotoxy(32,8);
      write('G N A W * W O R K ');
    gotoxy(34,12);
      write('MAIN MENU');
    gotoxy(29,14);
      write('1. Configure printer.');
    gotoxy(29,16);
      write('2. Print a file.');
    gotoxy(29,18);
      write('3. Quit Gnaw*work');
    gotoxy(29,20);
      Beep;
      read(kbd,Mode);
      write(Mode);
        case Mode of
          '1':Choice;
          '2':Choose;
        end;
      if Mode<>'3' then
        Menu;
        ClrScr;
  End;  {Procedure Menu}

{**********************************************}
{*   Main body of program SETUP begins here   *}
{**********************************************}


Begin;
  Menu;
End. {Program Setup}

