NBPrg40. N40T1.PAS. MiniOS. OpenSource.

NBPrg40. N40T1.PAS. MiniOS. OpenSource.
***************************************

{ Nikita Beloshenko (GNU) 2013  }

{ NBPRG23 -> ... -> NBPRG40 }

{ Nikita Beloshenko (GNU) 2012 }

Unit N40t1;

(*************************************
 *                                   *
 *   N40T1.PAS                       *
 *                                   *
 *   N40t1.                          *
 *                                   *
 *************************************)

Interface

Uses Graph, Crt;

Procedure DoTask1;

Implementation


Procedure DrawRectangle(Var x1,y1,x2,y2:Integer);
Begin
  Line(x1,y1,x2,y1);
  Line(x2,y1,x2,y2);
  Line(x2,y2,x1,y2);
  Line(x1,y2,x1,y1);
End;

Procedure DoTask1;
Var
  x1,y1,x2,y2 : Integer;
  ch1 : Char;
  k : Byte;
  TEMPFILE : Text;
  TMPF_S : String;
Begin
  x1 := 200; x2 := 500;
  y1 := 150; y2 := 450;

  SetFillStyle(0,SolidFill);
  Bar(x1,y1,x2,y2);

  ch1:=' ';

  While Ord(ch1)<>27 Do
  Begin
    SetColor(2);
    DrawRectangle(x1,y1,x2,y2);
    SetTextStyle(2, HorizDir, 5);
    OutTextXY(x1 + (x2-x1) Div 7,
              y1 + (y2-y1) Div 7,'task1');

    Assign(TEMPFILE,'task.tmp');
    ReWrite(TEMPFILE);
    {---- ~NBPRG3 FUNCTION -----}
    For k:=1 To 15 Do
    Begin
      WriteLn(TEMPFILE,'k = ',k,' f = ',(k+1)/k);
    End;
    {---- END(NBPRG3 FUNCTION) ----}
    Close(TEMPFILE);
    Assign(TEMPFILE,'task.tmp');
    Reset(TEMPFILE);
    {---- READ FROM TEMP FILE ----}
    k:=0;
    While Not eof(TEMPFILE) Do
    Begin
      Inc(k);
      ReadLn(TEMPFILE,TMPF_S);
      SetTextStyle(2, HorizDir, 5);
      OutTextXY(x1 + (x2-x1) Div 7,
                y1 + (y2-y1) Div 7 + k * (y2-y1) Div 20 ,TMPF_S);
    End;
    {---- END ----}
    Close(TEMPFILE);

    ch1 := ReadKey;
  End;
  SetFillStyle(0,SolidFill);
  Bar(x1,y1,x2,y2);
End;

End.