NBPrg40. (*graph.md). P_ED.PAS. MiniOS. OpenSource.

NBPrg40. (*graph.md). P_ED.PAS. MiniOS. OpenSource.
**************************************

{ Nikita Beloshenko (GNU) 2013 }

Unit p_ed;

(***********************************************
 *                                             *
 *   P_ED.PAS                                  *
 *                                             *
 *   p_ed.                                     *
 *                                             *
 ***********************************************)

Interface

Uses Graph, Crt; {(graph.md) = (module)(with)(using)(crt)}

Procedure p_ed_run;

Implementation

{Graph->Init}
Procedure Graph_Init;
Var
  gd,gm  : Integer; {graph}
Begin
  gd := Detect;
  InitGraph(gd,gm,'');
End;

{Print (plus.p)}
Procedure PrintP_File;
Var
  Str1 : String; {OutTextXY}

  i,j : Byte;
  t   : Text;

  c   : Byte;
Begin
  Assign(t,'plus.p');
  Reset(t);

  For i:= 1 To 16 Do
  Begin
    For j:=1 To 16 Do
    Begin
      Read(t,c);
      If c<10 Then
      Begin
        Str(c, Str1);
        Str1 := '0'+Str1+'  ';
        If c<>0 Then SetColor(c)
                    Else SetColor(White);
        OutTextXY(50 + j * 20 ,50 + i * 20,Str1);
        Circle(50 +10+ j * 20 , 50 + i * 20, 7);
      End Else
      Begin
        Str(c, Str1);
        Str1 := Str1+'  ';
        If c<>0 Then SetColor(c)
                    Else SetColor(White);
        OutTextXY(50 + j * 21 ,50 + i * 20,Str1);
        Circle(50 +10+ j * 21 , 50 + i * 20, 7);
      End;
    End;
  End;

  Close(t);
End;

{run}
Procedure p_ed_run;
Label START, EXIT;
Var
  Ch     : Char; {ReadKey}

  {Select : Byte;} {Ch for graph.md}
  X_,Y_  : Byte;
  Color  : Byte;
  c      : Byte;
  i,j    : Byte;

  t,t1   : Text;
Begin

START :

  Graph_Init;

  OutTextXY(50,10,'Nikita Beloshenko (GNU) 2013');
  OutTextXY(50,20,'NBPRG40. OS.');
  OutTextXY(50,30,'P_ED = (edit)(*.p)');
  OutTextXY(50,40,'plus.p');

  PrintP_File;

  SetColor(White);
  OutTextXY(50,400,'Press ENTER.');
  Ch := ReadKey;
  SetColor(Black);
  OutTextXY(50,400,'Press ENTER.');

  SetColor(White);
  OutTextXY(10,400,'1. Exit;');
  OutTextXY(10,410,'2. Edit.');
  OutTextXY(10,420,'Select?(1,2)');
  Ch := ReadKey;
  SetColor(Black);
  OutTextXY(10,400,'1. Exit;');
  OutTextXY(10,410,'2. Edit.');
  OutTextXY(10,420,'Select?(1,2)');

  If Ch='1' Then Goto EXIT;

  {CloseGraph;}
  {RestoreCrtMode;}
  {ClrScr;}  {text mode}

  TextColor(Yellow);
  TextBackGround(Blue);
  WriteLn('X_? (1..16)');
  SetColor(Yellow);
  OutTextXY(10,400,'X_? (1..16)');
  ReadLn(X_);
  SetColor(Black);
  OutTextXY(10,400,'X_? (1..16)');
  WriteLn('Y_? (1..16)');
  SetColor(Yellow);
  OutTextXY(10,400,'Y_? (1..16)');
  ReadLn(Y_);
  SetColor(Black);
  OutTextXY(10,400,'Y_? (1..16)');
  WriteLn('Color? (0..14)');
  SetColor(Yellow);
  OutTextXY(10,400,'Color? (0..14)');
  ReadLn(Color);
  SetColor(Black);
  OutTextXY(10,400,'Color? (0..14)');
  {ClrScr;}
  SetGraphMode(GetGraphMode);
  {Graph_Init;}

  {Build plus.tmp}
  Assign(t,'plus.p');
  Assign(t1,'plus.tmp');
  Reset(t);
  ReWrite(t1);
  For i := 1 To 16 Do
  Begin
    For j := 1 To 16 Do
    Begin
      Read(t,c);
      If ((j = X_) And (i = Y_)) Then
      Begin
        c := Color;
      End;

      {c in (0,1,2,3,4,5,6,7,8,9)?}
      {c in (10,11,12,13,14)?}
      If c<10 Then
      Begin
        Write(t1,'0',c,'  ');
      End Else
      Begin
        Write(t1,c,'  ');
      End;
    End;
    WriteLn(t1);
  End;
  Close(t);
  Close(t1);

  {ReWrite}
  Assign(t1,'plus.p');
  Assign(t,'plus.tmp');
  Reset(t);
  ReWrite(t1);
  For i := 1 To 16 Do
  Begin
    For j := 1 To 16 Do
    Begin
      Read(t,c);

      {c in (0,1,2,3,4,5,6,7,8,9)?}
      {c in (10,11,12,13,14)?}
      {(table)(format)}
      If c<10 Then
      Begin
        Write(t1,'0',c,'  ');
      End Else
      Begin
        Write(t1,c,'  ');
      End;
    End;
    WriteLn(t1);
  End;
  Close(t);
  Close(t1);

  SetColor(White);
  OutTextXY(10,400,'Press ENTER.');
  Ch := ReadKey;

  goto START;

EXIT :

  SetColor(White);
  OutTextXY(10,400,'Press ENTER.');
  Ch := ReadKey;

  CloseGraph;
End;

End.