program WiresTester;

uses Cables, Judging, Measure;

const Test = true;

procedure Init;
  begin
  writeln('Test environment for cable measurer') ;
  writeln('  Test = ', Test:1) ;
  Mode := RemoteAnswer ; Show := Test ;
  InitJudging(Evaluator) ;
  if ParamCount > 0 then begin
    writeln(LogFile, 'Method = ', ParamStr(1)) ;
    AbortRemote ;
    write('Executing MEASURER ', ParamStr(1)) ;
    WriteRemote('MEASURER ' + ParamStr(1)) ;
    WriteRemoteCR ;
    writeln
    end { if } ;
  SwallowEcho := true ; CRrepeat := 1 ;
  writeln('Initialized') ; writeln
  end { Init } ;

procedure Fini;
  begin
  Close(LogFile)
  end { Fini } ;

procedure DoIt;
  const pnsp = ['!'..'~'] ; { printable non-space characters }
  var
    ch: char; a: Wire; b: Switch; p: boolean; f: Connectivity;
  begin
  AskValues(a, b) ;
  while (a <> 0) and (b <> 0) do begin
    repeat
      SkipRemoteTo(pnsp, ch) ; ch := UpCase(ch) ;
      case ch of
        probeChr: p := Probe(a) ;
        changeChr: Change(b) ;
        doneChr: Done(f) ;
        else writeln(LogFile, 'Unknown command: ', ch)
        end { case }
      until ch = doneChr ;
{    repeat
      write('C(ontinue, Q(uit: ') ;
      readln(ch) ; ch := UpCase(ch)
      until ch in ['C', 'Q'] }
    writeln(LogFile) ;
    AskValues(a, b)
    end { while }
  end { DoIt } ;

begin
Init ;
DoIt ;
Fini
end.