Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-04 - decus/20-0109/decom.sim
There are 4 other files named decom.sim in the archive. Click here to see a list.
OPTIONS(/L/E); !/C/-A/-I/-D);
EXTERNAL TEXT	PROCEDURE rest, scanto, frontstrip, upcase,
			front, conc, checkextension;
EXTERNAL REF (Infile)	PROCEDURE findinfile;
EXTERNAL REF (Outfile)	PROCEDURE findoutfile;
EXTERNAL BOOLEAN	PROCEDURE frontcompare;
EXTERNAL CHARACTER	PROCEDURE findtrigger;
EXTERNAL INTEGER	PROCEDURE scanint, search;
EXTERNAL LONG REAL	PROCEDURE scanreal;
EXTERNAL		PROCEDURE split;
EXTERNAL		CLASS safmin;

COMMENT  DECOM --- Interpret user command with files and switches.;

safmin CLASS decom(limit);   INTEGER limit;
BEGIN
  TEXT ARRAY swarray[1:limit];
  TEXT dottext, colontext, switchchar, equal;
  INTEGER nswin, nswout, i;

  BOOLEAN PROCEDURE deccom(command,ohead,ihead);
  NAME ohead,ihead;
  TEXT command,ohead,ihead;
  BEGIN    TEXT outspec,inspec;
    INTEGER switchcount,i,noutswitches;

    TEXT PROCEDURE getswitch(t);   NAME t;    TEXT t;
    BEGIN   TEXT s;
      split(rest(t),s,switchchar,t);
      IF s == NOTEXT THEN
      BEGIN Outtext("%DECSWV - Switch Without Value.");
	Outimage; deccom:= FALSE;
      END;
      getswitch:- s
    END of getswitch;

    INTEGER PROCEDURE collectswitch(t,header);
    NAME header;   TEXT t,header;
    BEGIN
      header:- scanto(t,'/');
      WHILE t.More DO
      BEGIN
	IF switchcount >= limit THEN
	BEGIN   Outtext("%DECTMS - Too Many Switches.");
	  deccom:= FALSE; Outimage;   GO TO exit
	END;
	switchcount:= switchcount + 1;
	swarray[switchcount]:- getswitch(t);
      END;
      exit:
      collectswitch:= switchcount
    END of collectswitch;

    deccom:= TRUE;
    OPTIONS(/A);   swarray[1]:- swarray[1];
    swarray[limit]:- swarray[limit];
    COMMENT OPTIONS(/-A);

    split(command,outspec,equal,inspec);
    noutswitches:=
    switchcount:= collectswitch(outspec,ohead);
    switchcount:= collectswitch(inspec ,ihead);
    nswin:= switchcount - noutswitches;
    nswout:= noutswitches;

  END of deccom;

  OPTIONS(/p);
  PROCEDURE createfiles(ohead,ihead,oextension,iextension,
  ofile,ifile,help);
  NAME ohead,ihead,ofile,ifile,help;
  TEXT ohead, ihead, oextension, iextension;
  REF (Outfile) ofile;   REF (Infile) ifile;
  BOOLEAN  help;
  BEGIN
    REF (Outfile) ofile2;   REF (Infile) ifile2;

    ihead:- checkextension(ihead,iextension);
    ohead:- checkextension(ohead,oextension);
    FOR ifile2:- findinfile(ihead) WHILE ifile2 == NONE DO
    BEGIN   Outtext("%DECCFI - Cannot Find Infile:");
      Outtext(ihead);    Outimage;
      request("Enter new infile spec: ",nodefault,
      textinput(ihead,TRUE),NOTEXT,help);
    END check infile;

    IF ohead = "TTY:" THEN ofile2:- Sysout ELSE
    FOR ofile2:- findoutfile(ohead) WHILE ofile2 == NONE DO
    BEGIN   Outtext("?DECIOS Illegal Outfile Spec:");
      Outtext(ohead);   Outimage;
      request("Enter new outfile spec: ",nodefault,
	  textinput(ohead,TRUE),NOTEXT,help);
    END check outfile;

    ifile:- ifile2;   ofile:- ofile2;

  END of procedure create_files;
  OPTIONS(/p);


  PROCEDURE intswitch(id,default,result,okay,errmess,help);
  NAME default, id, result, okay, errmess, help;
  TEXT default, id, errmess; INTEGER result; BOOLEAN okay, help;
  BEGIN
    TEXT sw;
    FOR i:= nswin+nswout STEP -1 UNTIL 1 DO
    IF frontcompare(swarray[i],id) THEN
    BEGIN
      sw:- swarray[i]; sw.Setpos(1); scanto(sw,':');
      swarray[i]:- NOTEXT;
      GO TO out
    END;
    IF default == NOTEXT THEN GOTO askforvalue ELSE
    sw:- Copy(default);
    out:
    result:= scanint(sw);
    IF NOT okay THEN
    BEGIN
      Outtext("?DECISV - Illegal Switch Value /"); Outtext(id);
      Outchar(':'); Outint(result,8); Outimage;
      outline(errmess);
      askforvalue: request(id,default,intinput(result,okay),errmess,help);
    END;
  END of intswitch;


  BOOLEAN PROCEDURE boolswitch(id,okay,errmess,help);
  NAME id, okay, errmess, help;
  TEXT id, errmess; BOOLEAN okay, help;
  BEGIN
    TEXT sw; BOOLEAN result;
    FOR i:= nswin+nswout STEP -1 UNTIL 1 DO
    IF frontcompare(swarray[i],id) THEN
    BEGIN
      result:= TRUE;
      swarray[i]:- NOTEXT;
      WHILE result AND NOT okay DO
      BEGIN
	Outtext("?DECISV - Illegal Switch Value: /"); Outtext(id);
	Outimage;
	outline(errmess);
	request(id,"NO",boolinput(result),errmess,help);
      END;
      out:
    END;
    out:
    boolswitch:= result;
  END of boolswitch;


  BOOLEAN PROCEDURE illegalswitch(errmess,help);
  NAME errmess, help; TEXT errmess;   BOOLEAN help;
  BEGIN
    FOR i:= nswin+nswout STEP -1 UNTIL 1 DO
    BEGIN
      IF swarray[i] =/= NOTEXT THEN
      BEGIN
	upcase(swarray[i]);   swarray[i].Setpos(1);
	IF swarray[i].Getchar = '?' OR swarray[i] = "H"
	OR swarray[i] = "HE" OR
	swarray[i] = "HEL" OR swarray[i] = "HELP" THEN
	BEGIN   IF help THEN ; END ELSE
	BEGIN
	  Outtext(errmess); Outtext(swarray[i]);
	  Outimage;
	END;
	illegalswitch:= TRUE;
      END;
    END;
  END;

  dottext:- Copy(".:/=");
  equal:- dottext.Sub(4,1);
  switchchar:- dottext.Sub(3,1);
  colontext:- dottext.Sub(2,1);
  dottext:- dottext.Sub(1,1);

END of decom;