home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / norskdata / ndkdco.pas < prev    next >
Pascal/Delphi Source File  |  2020-01-01  |  7KB  |  218 lines

  1. (* Tab p; *)
  2. procedure   DoCommands;
  3. var     Verb, Noun, Adj : VocabType;
  4.         ParBlock        : ParType;
  5.         FileList        : NListPtr;
  6.  
  7.     procedure   BgnStat;
  8.     (* Begin registration of statistics *)
  9.     begin(* BgnStst *)
  10.         StartCpTime := xtusd;       (* For description see main VAR-section *)
  11.         StartTime := xtime;         (* (in file Kermit-Vars)                *)
  12.         NChSent := 0L;
  13.         NChRcvd := 0L;
  14.         NChFile := 0L;
  15.     end; (* BgnStst *)
  16.  
  17.     procedure   EndStat;
  18.     (* End registration of statistics *)
  19.     begin (* EndStat *)
  20.         StopCpTime := xtusd;
  21.         StopTime := xtime;
  22.     end;  (* EndStat *)
  23.  
  24.     procedure   DoSet( Noun, Adj : VocabType; ParBlock: ParType );
  25.  
  26.         procedure   DoSRcv( Adj : VocabType; Par: ParType );
  27.         begin(* DoSRcv *)
  28.             case Adj of
  29.                 TimeOutSym  :
  30.                     begin
  31.                         RTSet := true;
  32.                         RcvTimeOut := Par.int;
  33.                     end;
  34.             end;
  35.             writeln;
  36.         end; (* DoSRcv *)
  37.  
  38.         procedure   DoSSend( Adj : VocabType; Par: ParType );
  39.         begin (* DoSSend *)
  40.             case Adj of
  41.                 TimeOutSym  :
  42.                     begin
  43.                         STSet := true;
  44.                         SendTimeOut := Par.int;
  45.                     end;
  46.             end;
  47.             writeln;
  48.         end;  (* DoSSend *)
  49.  
  50.         procedure   DoSetDebug( Adj : VocabType; Par: ParType );
  51.         begin(* DoSetDebug *) 
  52.             case Adj of
  53.                 OnSym   :
  54.                     begin
  55.                         if Debug then
  56.                             write(' Debug is already on.')
  57.                         else
  58.                             if not DbgConnected then
  59.                                 write(' Error: No debug file defined')
  60.                             else
  61.                                 Debug := true;
  62.                     end;
  63.                 OffSym  :
  64.                     begin
  65.                         if not Debug then
  66.                             write(' Debug was already off.')
  67.                         else
  68.                             Debug := false;
  69.                     end;
  70.                 LogFileSym  :
  71.                     begin
  72.                         if DbgConnected then
  73.                             disconnect(DbgOut);
  74.                         (* Add terminator: *)
  75.                         Par.Name.String(.Par.Name.Valid + 1.) := '''';
  76.                         (* Open with Append access *)
  77.                         connect(DbgOut,Par.Name.String,'SYMB','WA',Status);
  78.                         if Status <> 0 then
  79.                             write(' Could not open debug file.')
  80.                         else
  81.                         begin
  82.                             Debug := true;
  83.                             DbgConnected := true;
  84.                             rewrite(DbgOut);
  85.                         end;
  86.                     end;
  87.                 NoLogFileSym:
  88.                     begin
  89.                         if not DbgConnected then
  90.                             write(' No debug file open.')
  91.                         else
  92.                         begin
  93.                             disconnect(DbgOut);
  94.                             Debug := false;
  95.                             DbgConnected := false;
  96.                         end;
  97.                     end;
  98.             end;
  99.             writeln;
  100.         end; (* DoSetDebug *)
  101.  
  102.         procedure   DoS8Quo( Adj : VocabType );
  103.         begin (* DoS8Quo *)
  104.             case Adj of
  105.                 AutoSym :   HasSw8Off := false;
  106.                 OffSym  :   HasSw8Off := true;
  107.             end;
  108.             writeln;
  109.         end;  (* DoS8Quo *)
  110.  
  111.         procedure   DoSFWarn( Adj : VocabType );
  112.         begin (* DoSFWarn *)
  113.             case Adj of
  114.                 OnSym   :   FileWarning := true;
  115.                 OffSym  :   FileWarning := false;
  116.             end;
  117.             writeln;
  118.         end;  (* DoSFWarn *)
  119.  
  120.     begin (* DoSet *)
  121.         case Noun of
  122.             DbgSym  :   DoSetDebug( Adj, ParBlock );
  123.             DelaySym:
  124.                 begin
  125.                     Delay := ParBlock.int;
  126.                     writeln;
  127.                 end;
  128.             RcvSym  :   DoSRcv  ( Adj, ParBlock );
  129.             SendSym :   DoSSend ( Adj, ParBlock );
  130.             Use8Sym :   DoS8Quo ( Adj );
  131.             FWarnSym:   DoSFWarn( Adj );
  132.         end;
  133.     end; (* DoSet *)
  134.  
  135.     procedure   DoStatistics;
  136.  
  137.         procedure   WrtTimeLN( time : longint );
  138.         begin (* WrtTimeLN *)
  139.             writeln( time div(50L*60L)        :3,' min',
  140.                    (time mod(50L*60L)) div 50L:3,' sec');
  141.         end;  (* WrtTimeLN *)
  142.  
  143.         procedure   OutInfo( NChF, NChX, NChR, RTime, CPTime, BdRat : longint );
  144.         begin (* OutInfo *)
  145.             writeln('Number of chars. to/from file   :', NChF:5);
  146.             writeln('Number of characters sent       :', NChX:5);
  147.             writeln('Number of characters received   :', NChR:5);
  148.               write('Real time used for transaction  :');
  149.                     WrtTimeLN( RTime );
  150.               write('Computer time used for same     :');
  151.                     WrtTimeLN( CPTime );
  152.               write('Effective baud rate to/from file:', BdRat:5,' baud');
  153.         end;  (* OutInfo *)
  154.  
  155.     begin(* DoStatistics *)
  156.         if not HasDone then
  157.         begin
  158.             write(' No transaction has been made yet.');
  159.             writeln;
  160.             OutInfo( 0L, 0L, 0L, 0L, 0L, 0L );
  161.         end
  162.         else
  163.         begin
  164.             writeln;    (* to get new line after command line *)
  165.             OutInfo(    NChFile,
  166.                         NChSent,
  167.                         NChRcvd,
  168.                         StopTime - StartTime,
  169.                         StopCpTime - StartCpTime,
  170.                         NChFile * 10L div( (StopTime-StartTime) div 50L )
  171.                     );
  172.         end;
  173.         writeln; 
  174.     end; (* DoStatistics *)
  175.  
  176. begin (* DoCommands *)
  177.     repeat
  178.         brkm(0);    (* Break on all characters *)
  179.         echom(-1);  (* no echo *)
  180.         GetCmd(Verb,Noun,Adj,ParBlock);
  181.         case Verb of
  182.             ExitSym,QuitSym     :   ;
  183.             HelpSym     :
  184.                 begin
  185.                     writeln;
  186.                     DoHelp;
  187.                 end;
  188.             RcvSym      :
  189.                 begin
  190.                     writeln;
  191.                     DidRcv := true;
  192.                     HasDone := true;
  193.                     BgnStat;
  194.                     CurrState :=
  195.                         ReadSwitch( OutFile, Idev, Odev );
  196.                     EndStat;
  197.                 end;
  198.             SendSym     :
  199.                 begin
  200.                     writeln;
  201.                     if BuildList( ParBlock.Name, FileList ) then begin
  202.                         writeln(' - Ok');
  203. (*                      ShowList( FileList );       *)
  204.                         DidRcv := false;
  205.                         HasDone := true;
  206.                         BgnStat;
  207.                         CurrState :=
  208.                             SendSwitch( FileList, InFile, Idev, Odev );
  209.                         EndStat;
  210.                     end;
  211.                 end;
  212.             SetSym      :   DoSet( Noun, Adj, ParBlock );
  213.             StatisticsSym:  DoStatistics;
  214.         end;
  215.     until ( Verb = ExitSym ) or ( Verb = QuitSym );
  216. end; (* DoCommands *)
  217. 
  218.