NBPrg40. (*CFProc_). CFPROC1.PAS. MiniOS. OpenSource.

NBPrg40. (*CFProc_). CFPROC1.PAS. MiniOS. OpenSource.
***************************************

{ Nikita Beloshenko (GNU) 2013 }

Unit CFProc1;

(***********************************************
 *                                             *
 *   CFPROC1.PAS                               *
 *                                             *
 *   CFProc1.                                  *
 *                                             *
 ***********************************************)

Interface

Procedure CFProc1_run;

Implementation

Uses MTest,
{ --------------------- }
     HISTOGR,
     EDSFILE,
     CPFILE,
     EDFILE,
     TYFILE,
     CRFILE,
     CONCALC,
     TREE,
     MY1,
     MY,
     MTest1;

Const
  CFProc1_AlgoFile = 'CFProc1.dat'; { FILE }

Type
  S30 = String[30];

{ FROM TWRITELN }
Procedure CFProc1_do_command(Var Task:S30);
Begin
  If (task=' HISTOGR') Then HISTOGR_run;
  If (task=' File->(Edit)->(With Search)') Then Edit_S_FILE_run;
  If (task=' File->(Copy)') Then CopyFILE_run;
  If (task=' File->(Edit)') Then EditFILE_run;
  If (task=' Type File') Then TypeFILE_run;
  If (task=' Create Text File') Then CRFILE_run;
  If (task=' Console Calc') Then CONCALC_run;
  If (task=' TREE') Then TREE_run;
  If (task=' MY1') Then MY1_run;
  If (task=' MY') Then MY_run;
End;

Procedure CFProc1_run;
Var
  T : Text;
  S : String;
  Num_ : Byte;
  i   : Byte;
  Num : Array[1..150] Of Byte;
  Buf : Array[1..150] Of S30;

  j,j1 : Byte;
  IF_File_Name : String;
  Str1,Str2 : String;
  TRUE_STRING : String;
  NUMBER_STRING : String;

  T1 : Text;
  NUM_GOTO :Byte;
  j2 : Byte;

Begin
  WriteLn(' Nikita Beloshenko (GNU) 2013 ');
  WriteLn(' ----- CFProc1 2013 {(algo) (module)} ----- ');

  assign(T,CFProc1_AlgoFile);
  reset(T);
  i:=0;
  While Not eof(T) Do
  Begin
    Inc(i);
    ReadLn(T,Num_,S);
    { CFProc_do_command(S); } { Without FOR }
    If i<150 Then
    Begin
      Num[i]:=Num_;
      Buf[i]:=S;
      Buf[i+1]:=' END';
    End;
  End;
  close(T);

  i:=1;
  While (i<150)And(Buf[i]<>' END') Do
  Begin
    Str1:=Buf[i];
    Str2:='IF';
    If (Pos(Str2,Str1)=0) Then
    Begin
      CFProc1_do_command(Buf[i]);
    End Else
    Begin
      j:=Pos('(',Str1);
      j1:=Pos(')',Str1);
      IF_File_Name := Copy(Str1,j+1,j1-j-1);
      Assign(T,IF_File_Name);
      Reset(T);
      ReadLn(T,TRUE_STRING);
      If TRUE_STRING='TRUE' Then
      Begin
        j:=Pos('[',Str1);
        j1:=Pos(']',Str1);
        NUMBER_STRING := Copy(Str1,j+1,j1-j-1);
        Assign(T1,'NUM.TMP');
        ReWrite(T1);
        WriteLn(T1,NUMBER_STRING);
        Close(T1);
        Assign(T1,'NUM.TMP');
        Reset(T1);
        ReadLn(T1,NUM_GOTO);
        Close(T1);
        j2 := 1;
        While (Buf[j2]<>' END')and(j2<150) Do
        Begin
          If(Num[j2]=NUM_GOTO) Then
          Begin
            i := j2 - 1;
          End;
          Inc(j2);
        End;
      End;
      Close(T);
    End;
    Inc(i);
  End;
End;

End.