NBPrg40. TWriteLn. MiniOS. OpenSource.

NBPrg40. TWriteLn. MiniOS. OpenSource.
***************************************

{ Beloshenko Nikita 2013 (GNU) }

(*

     TWRITELN.PAS

*)

Program Test_WriteLn;

Uses MTest,
{ ----- frag1:agc2723djdnw3hdknkdn3h83dms ----- }
     CFPROC1,
     CFPROC,
     NBPRG40U,
     HISTOGR,
     EDSFILE,
     CPFILE,
     EDFILE,
     TYFILE,
     CRFILE,
     CONCALC,
     TREE,
     MY1,
     MY,
{ ----- frag1:agc272dmflkse9ekrm9t5kl5095 ----- }
     MTest1;


Label EXIT_label,START_label;
Var task:String;
    tasks:Array[1..100] Of String;
    N_TASK_VAR,i:Byte;

{ ADD_NEW_TASK }
Procedure add_new_task_run;
Var T,T1:text; TempS:String;
    T2:text; TFILENAME : String;

    MODULE_UNIT : String;
    MODULE_NAME : String;
    MODULE_PROCEDURE : String;

    T3,T3_:text;

Begin
  { SELF REWRITING }
  assign(T,'TWRITELN.PAS');
  assign(T1,'TWRITELN.TMP');
  reset(T);
  rewrite(T1);
  While Not eof(T) Do
  Begin
    readln(T,TempS);
    writeln(T1,TempS);
  End;
  close(T);
  close(T1);

  { ADD->TASK (FROM FILE) }
  WRITELN(' ----- TASK FILE NAME? ----- ');
  WRITELN(' Sample:My.ts');
  READLN(TFILENAME);
  assign(T2,TFILENAME); reset(T2);
  {MY.TS - test}

  MODULE_UNIT := '';
  MODULE_NAME := '';
  MODULE_PROCEDURE := '';

  If Not eof(T2) Then readln(T2,MODULE_UNIT);
  If Not eof(T2) Then readln(T2,MODULE_NAME);
  If Not eof(T2) Then readln(T2,MODULE_PROCEDURE);

  If MODULE_NAME <> '' Then
  Begin
    { ADD MODULE NAME TO TASK LIST }
    assign(T3,'MMLIST.TCK');
    assign(T3_,'MMLIST.BAK');
    reset(T3);
    rewrite(T3_);
    While Not eof(T3) Do
    Begin
      readln(T3,TempS);
      writeln(T3_,TempS);
    End;
    close(T3);
    close(T3_);

    assign(T3,'MMLIST.BAK');
    assign(T3_,'MMLIST.TCK');
    reset(T3);
    rewrite(T3_);
    writeln(T3_,MODULE_NAME);
    While Not eof(T3) Do
    Begin
      readln(T3,TempS);
      writeln(T3_,TempS);
    End;
    close(T3);
    close(T3_);
  End;

  assign(T,'TWRITELN.TMP');
  assign(T1,'TWRITELN.PAS');
  reset(T);
  rewrite(T1);
  While Not eof(T) Do
  Begin
    readln(T,TempS);
    writeln(T1,TempS);
    If(TempS='{ ----- frag1:agc2723djdnw3hdknkdn3h83dms ----- }') Then
    Begin
      If MODULE_UNIT<>'' Then
      Begin
        writeln(T1,'     ',MODULE_UNIT,',');
      End;
    End;
    If(TempS='{ ----- frag2:sjdnakdn8291agc27kdn3h83dms ----- }') Then
    Begin
      If (MODULE_NAME<>'') And (MODULE_PROCEDURE<>'') Then
      Begin
        writeln(T1,'  If (task=''',MODULE_NAME,''') Then ',MODULE_PROCEDURE,';');
      End;
    End;
  End;
  close(T);
  close(T1);

  close(T2);
End;

{ DELETE TASK }
Procedure delete_task_run;
Var
  T,T1:text; TempS:String;
  T2:text; TFILENAME : String;

  MODULE_UNIT : String;
  MODULE_NAME : String;
  MODULE_PROCEDURE : String;

  TempIFCmdS : String;
  T_IFCMDStmp : text;

Begin

  { SELF REWRITING }
  assign(T,'TWRITELN.PAS');
  assign(T1,'TWRITELN.TMP');
  reset(T);
  rewrite(T1);
  While Not eof(T) Do
  Begin
    readln(T,TempS);
    writeln(T1,TempS);
  End;
  close(T);
  close(T1);

  { DELETE TASK . GET DATA ABOUT TASK . }
  WRITELN(' ----- TASK FILE NAME? ----- ');
  WRITELN(' Sample:My.ts');
  READLN(TFILENAME);
  assign(T2,TFILENAME); reset(T2);
  {MY.TS - test}

  MODULE_UNIT := '';
  MODULE_NAME := '';
  MODULE_PROCEDURE := '';

  If Not eof(T2) Then readln(T2,MODULE_UNIT);
  If Not eof(T2) Then readln(T2,MODULE_NAME);
  If Not eof(T2) Then readln(T2,MODULE_PROCEDURE);

  Close(T2);

  { DELETE TASK . SELF REWRITING . }
  assign(T,'TWRITELN.TMP');
  assign(T1,'TWRITELN.PAS');
  reset(T);
  rewrite(T1);
  While Not eof(T) Do
  Begin
    readln(T,TempS);
    If(TempS='{ ----- frag1:agc2723djdnw3hdknkdn3h83dms ----- }') Then
    Begin
      While((TempS<>'{ ----- frag1:agc272dmflkse9ekrm9t5kl5095 ----- }')And(Not eof(T))) Do
      Begin
        If MODULE_UNIT<>'' Then
        Begin
          If(TempS='     '+MODULE_UNIT+',')Then
          Begin
            TempS := TempS;
          End Else
          Begin
            writeln(T1,TempS);
          End;
        End Else
        Begin
          writeln(T1,TempS);
        End;
        readln(T,TempS);
      End;
      If(TempS='{ ----- frag1:agc272dmflkse9ekrm9t5kl5095 ----- }')Then
      Begin
        writeln(T1,TempS);
      End;
    End Else
    Begin
      If(TempS='{ ----- frag2:sjdnakdn8291agc27kdn3h83dms ----- }') Then
      Begin
        While((TempS<>'{ ----- frag2:sfnkueei9454jmlkty96kyhg69o ----- }')And(Not eof(T))) Do
        Begin
          If (MODULE_NAME<>'') And (MODULE_PROCEDURE<>'') Then
          Begin
            Assign(T_IFCMDStmp,'IFCMDS.TMP');
            ReWrite(T_IFCMDStmp);
            WriteLn(T_IFCMDStmp,'  If (task=''',MODULE_NAME,''') Then ',MODULE_PROCEDURE,';');
            Close(T_IFCMDStmp);
            Assign(T_IFCMDStmp,'IFCMDS.TMP');
            Reset(T_IFCMDStmp);
            ReadLn(T_IFCMDStmp,TempIFCmdS);
            Close(T_IFCMDStmp);
            If(TempS=TempIFCmdS)Then
            Begin
              TempS := TempS;
            End Else
            Begin
              writeln(T1,TempS);
            End;
          End Else
          Begin
            writeln(T1,TempS);
          End;
          readln(T,TempS);
        End;
        If(TempS='{ ----- frag2:sfnkueei9454jmlkty96kyhg69o ----- }')Then
        Begin
          writeln(T1,TempS);
        End;
      End Else
      Begin
        writeln(T1,TempS);
      End;
    End;
  End;
  close(T);
  close(T1);

  { DELETE TASK . MMLIST.TCK }
  Assign(T,'MMLIST.TCK');
  Assign(T1,'MMLIST.TMP');
  Reset(T);
  ReWrite(T1);
  While Not eof(T) Do
  Begin
    ReadLn(T,TempS);
    WriteLn(T1,TempS);
  End;
  Close(T);
  Close(T1);

  Assign(T,'MMLIST.TCK');
  Assign(T1,'MMLIST.TMP');
  Reset(T1);
  ReWrite(T);
  While Not eof(T1) Do
  Begin
    ReadLn(T1,TempS);
    If(MODULE_NAME<>'') Then
    Begin
      If(TempS=MODULE_NAME)Then
      Begin
        TempS:=TempS;
      End Else
      Begin
        WriteLn(T,TempS);
      End;
    End Else
    Begin
      WriteLn(T,TempS);
    End;
  End;
  Close(T);
  Close(T1);

End;

{ PROCESSOR }
Procedure processor_run;
Begin

  { ADD NEW TASK }
  If(task='ADD NEW TASK') Then add_new_task_run;

  { DELETE TASK }
  If(task='DELETE TASK') Then delete_task_run;

  { PLACE TO WORK WITH COMMAND }
  { -------------------------- }

{ ----- frag2:sjdnakdn8291agc27kdn3h83dms ----- }
  If (task='CFprocessor1') Then CFPROC1_run;
  If (task='CFprocessor') Then CFPROC_run;
  If (task='GraphModule') Then NBPRG40U_run;
  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;
{ ----- frag2:sfnkueei9454jmlkty96kyhg69o ----- }


End;

{ MAIN MODULE }
Var T4:text;
Begin

  { READ MMLIST.TCK }

  assign(T4,'MMLIST.TCK');
  reset(T4);
  N_TASK_VAR := 0;
  While Not eof(T4) Do Begin
    Inc(N_TASK_VAR);
    readln(T4,tasks[N_TASK_VAR]);
  End;
  close(T4);

START_label : { START }

  WriteLn(' ----- T E S T ----- {(text)(OS)} ----- ');
  WriteLn(' Beloshenko Nikita 2013 (GNU) ');
  WriteLn(' -------------------------------------- ');
  WriteLn('');

  WriteLn('Type E+M+M to exit.');
  WriteLn('HELP = MAIN MODULE -> {(TASK)(LIST)}.');
  WriteLn('MAIN MODULE : ENTER?');
  ReadLn(task);

  { HELP }
  If(task='HELP') Then
  Begin
    WriteLn(' ----- HELP ----- ');
    For i := 1 To N_TASK_VAR Do
    Begin
      WriteLn(i,').',tasks[i]);

      { BLOCK = 5 tasks }
      { Pause. }
      If i Mod 5 = 0 Then
      Begin
        WriteLn(' ---- Press ENTER to see next ---- ');
        Write(' ----  group of   T A S K S.  ---- ');
        ReadLn;
      End;
    End;
  End;

  { PROCESSOR }
  processor_run;

  { E+M+M }
  If(task='E+M+M') Then
  Begin
    Goto EXIT_label;  { EXIT }
  End Else
  Begin
    Goto START_label; { RELOAD }
  End;

EXIT_label:

  { END }
End.