Trailing-Edge
-
PDP-10 Archives
-
decuslib20-03
-
decus/20-0078/libsim/decom.sim
There are 4 other files named decom.sim in the archive. Click here to see a list.
OPTIONS(/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.;
! See DECOM.HLP;
safmin CLASS decom(limit); INTEGER limit;
BEGIN
TEXT ARRAY swarray[1:limit];
TEXT dottext, colontext, switchchar, equal;
INTEGER nswin, nswout, i;
CHARACTER c;
BOOLEAN PROCEDURE deccom(command,ospec,ispec);
NAME ospec,ispec;
TEXT command,ospec,ispec;
IF command =/= NOTEXT THEN
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,ospec);
switchcount:= collectswitch(inspec ,ispec);
nswin:= switchcount - noutswitches;
nswout:= noutswitches;
END of deccom;
OPTIONS(/p);
PROCEDURE createfiles(ospec,ispec,oextension,iextension,
ofile,ifile,help);
NAME ospec,ispec,ofile,ifile,help;
TEXT ospec, ispec, oextension, iextension;
REF (Outfile) ofile; REF (Infile) ifile;
BOOLEAN help;
BEGIN
REF (Outfile) ofile2; REF (Infile) ifile2;
ispec:- checkextension(ispec,iextension);
ospec:- checkextension(ospec,oextension);
IF ispec = "TTY:" THEN ifile2:- Sysin ELSE
FOR ifile2:- findinfile(ispec) WHILE ifile2 == NONE DO
BEGIN Outtext("%DECCFI - Cannot Find Infile:");
Outtext(ispec); Outimage;
request("Enter new infile spec: ",nodefault,
textinput(ispec,TRUE),NOTEXT,help);
END check infile;
IF ospec = "TTY:" THEN ofile2:- Sysout ELSE
BEGIN
IF findinfile(ospec) =/= NONE THEN
BEGIN outtext("%Overwriting file: "); outtext(ospec);
outtext(" OK?"); breakoutimage; inimage;
c:= inchar; IF c ne 'Y' and c ne 'y' THEN
ospec:- NOTEXT;
END;
FOR ofile2:- findoutfile(ospec) WHILE ofile2 == NONE DO
BEGIN Outtext("?DECIOS Illegal Outfile Spec:");
Outtext(ospec); Outimage;
request("Enter new outfile spec: ",nodefault,
textinput(ospec,TRUE),NOTEXT,help);
END check outfile;
END;
ifile:- ifile2; ofile:- ofile2;
END of procedure create_files;
BOOLEAN PROCEDURE switchcompare(input,spec); VALUE spec;
TEXT input, spec;
IF input =/= NOTEXT THEN
BEGIN input.Setpos(1);
input:- scanto(input,':');
switchcompare:= frontcompare(spec,input)
END of switchcompare;
PROCEDURE textswitch(id,default,result,okay,errmess,help);
NAME default, id, result, okay, errmess, help;
TEXT default, id, errmess, result; BOOLEAN okay, help;
BEGIN
TEXT sw;
FOR i:= nswin+nswout STEP -1 UNTIL 1 DO
IF switchcompare(swarray[i],id) THEN
BEGIN
sw:- swarray[i]; sw.Setpos(1); scanto(sw,':');
swarray[i]:- NOTEXT; GO TO found
END;
IF default == NOTEXT THEN GOTO askforvalue ELSE
sw:- Copy(default);
found: result:- rest(sw);
IF NOT okay THEN
BEGIN
Outtext("?DECISV - Illegal Switch Value /"); Outtext(id);
Outtext(result); Outimage;
outline(errmess);
askforvalue:
request(id,default,textinput(result,okay),errmess,help);
END;
END of textswitch;
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 switchcompare(swarray[i],id) THEN
BEGIN
sw:- swarray[i]; sw.Setpos(1); scanto(sw,':');
swarray[i]:- NOTEXT; GO TO found
END;
IF default == NOTEXT THEN GOTO askforvalue ELSE
sw:- Copy(default);
found: result:= scanint(sw);
IF NOT okay THEN
BEGIN
Outtext("?DECISV - Illegal Switch Value /"); Outtext(id);
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 switchcompare(swarray[i],id) THEN
BEGIN
result:= TRUE;
swarray[i]:- NOTEXT;
i:= 0; ! Terminates loop!;
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;
END;
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 (IF swarray[i].Getchar = '?' THEN TRUE ELSE
frontcompare(Copy("HELP"),swarray[i]) ) THEN
BEGIN IF help THEN ; END ELSE
BEGIN
Outtext(errmess); Outtext(swarray[i]);
Outimage; Outtext("Retype command. ");
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;