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

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

{ Nikita Beloshenko (GNU) 2013 }

Unit p_ed;

(**************************************
 *                                    *
 *   P_ED.PAS                         *
 *                                    *
 *   P_ed.                            *
 *                                    *
 **************************************)

Interface

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

Procedure p_ed_run;

Implementation

{Print (plus.p)}
Procedure PrintP_File;
Var
  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
        Write('0',c,'  ');
      End Else
      Begin
        Write(c,'  ');
      End;
    End;
    WriteLn;
  End;

  Close(t);
End;

{run}
Procedure p_ed_run;
Label START, EXIT;
Var
  Select : Byte;
  X_,Y_  : Byte;
  Color  : Byte;
  c      : Byte;
  i,j    : Byte;

  t,t1   : Text;
Begin

START :

  ClrScr;

  WriteLn('Nikita Beloshenko (GNU) 2013');
  WriteLn('NBPRG39. OS.');
  WriteLn('P_ED = (edit)(*.p)');
  WriteLn('plus.p');

  PrintP_File;

  WriteLn('Press ENTER.');
  ReadLn;

  WriteLn('1. Exit;');
  WriteLn('2. Edit.');
  WriteLn('Select?(1,2)');
  ReadLn(Select);

  If Select=1 Then Goto EXIT;

  WriteLn('X_? (1..16)');
  ReadLn(X_);
  WriteLn('Y_? (1..16)');
  ReadLn(Y_);
  WriteLn('Color? (0..14)');
  ReadLn(Color);

  {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);


  WriteLn('Press ENTER.');
  ReadLn;

  Goto START;

EXIT :

  WriteLn('Press ENTER.');
  ReadLn;
End;

End.