C CATCHALL.FTN R RHODERICK JUNE 1982 C Catchall task called by MCR when MCR cannot parse a command. C This task should be installed as "...CA." C V 2.0 Added ERAse screen command AUG 1983 C V 2.1 NOV 1983 C Added flying install-run-remove C of tasks from LB:[1,54] & LB:[2,54] C V 2.3 NOV 1984 C Added interpretation of DSP or C DIS(PLAY) commands to "RMSDSP", C to run uninstalled LB:[1,54]RMSDSP task C C V 2.4 Added DCL-like DEL, DIR, PUR, TYP JAN 1985 C Also mapped D to DIR, T to TYP character spwnln*100,filenm*28,cmd*80,arg*84,cr,dummy character pipcmd(3)*3,pipsw(3)*3 integer param(6),cmdl,argl real mcr data cr/"15/ data mcr/6rMCR.../ data dummy/0/ data pipcmd/'DEL','DIR','PUR'/ data pipsw/'/DE','/LI','/PU'/ call errset(29,.true.,,,.false.,) ! no msg on no such file errors call errset(43,.true.,,,.false.,) ! no file specification errors msg call errset(68,.true.,,,.false.,) ! no variable format errors msg call getlun(2,param) param(2)=param(2).and."377 call getmcr(cmd,cmdl) C--remove the command verb from the rest of the command line C command verb is delineated by a trailing blank or slash argl=cmdl ibl=index(cmd(:cmdl),' ') isl=index(cmd(:cmdl),'/') if(ibl.gt.0.and.isl.gt.0)cmdl=min(ibl,isl)-1 if(ibl.eq.0.or.isl.eq.0)cmdl=max(ibl,isl)-1 if(cmdl.le.0)cmdl=argl argl=argl-cmdl if(argl.gt.0)arg=cmd(cmdl+1:) if(cmd(:3).ne.'SDF')goto 50 C--SDF command spwnln='SET /UIC=[' n=8 if(argl.lt.3)goto 900 !SDF command with no argument? 10 spwnln(11:)=arg(2:argl) n=10+argl spwnln(n:n)=']' goto 900 C--see if its an ERAse screen command 50 if(cmd(:3).ne.'ERA')goto 100 call getadr(param,dummy) !address of dummy buffer param(2)=1 !single character qio param(3)="100401 !TTDRV independent cursor control: !clear screen, position to line 1, col 1 call wtqio("400,2,2,,,param) goto 999 C--check if its a DEL, DIR, PUR, or TYP command 100 if(cmdl.gt.1)goto 105 if(cmd(:1).ne.'T')goto 102 cmd(:3)='TYP' !map T command to TYP cmdl=3 102 if(cmd(:1).ne.'D')goto 105 cmd(:3)='DIR' !map D command to DIR cmdl=3 105 do 110 i=1,3 if(cmd(:3).eq.pipcmd(i))goto 130 !check for DEL, DIR or PUR 110 continue if(cmd(:3).ne.'TYP')goto 150 !check for TYP C--TYP command if(argl.gt.0)goto 120 !TYP command must have argument write(2,115) 115 format(' TYP -- no file(s) specified') goto 999 120 cmd(1:)=' TI:=' cmd(6:)=arg(2:argl) !skip the argument's leading blank argl=argl+4 arg(1:)=cmd(:argl) !replace the command string cmd(1:)='TYP' !replace the command goto 140 C--DEL, DIR, or PUR command 130 arg(argl+1:)=pipsw(i) !add appropriate PIP switch argl=argl+3 140 filenm(:4)='$PIP' !name of file to RUN ifl=8 goto 830 !go RUN PIP with command string 150 if(cmd(:3).ne.'DSP'.and.cmd(:3).ne.'DIS')goto 200 C--DSP and DIS(PLAY) commands - run RMSDSP (RMS file discription) utility cmd(:3)='DSP' cmdl=3 filenm(:7)='$RMSDSP' ifl=11 goto 830 C--INSERT ADDITIONAL COMMANDS BELOW HERE ******************** C************************************************************ C--start code for next command here 200 continue C--start code for next command here 300 continue C************************************************************ C--INSERT ADDITIONAL COMMANDS ABOVE HERE ******************** C--Check to see if maybe the user wants to run a non-installed task located C either in the system UIC ( [1,54] ) or the USEPA utility task account C ( [2,54] ), or see if the user wants to execute a command file from the C USEPA utility command file account ( [2,24] ). if(cmd(1:1).lt.'0'.or.cmd(1:1).gt.'z')goto 890 if(cmd(1:1).gt.'9'.and.cmd(1:1).lt.'A')goto 890 if(cmd(1:1).gt.'Z'.and.cmd(1:1).lt.'a')goto 890 C--see if a task exists in LB:[1,54] or LB:[2,54] with the same name as the C user's command - if there is, run it with the command line: C RUN $XXXXXXXXX/TASK=xxxTnn/CMD="Xargument" C - or - C RUN LB:[2,54]XXXXXXXXX/TASK=xxxTnn/CMD="Xargument" C where XXXXXX is the task name, xxx is the first three letters of the task C name, nn is the user's terminal number (or Hnn if from a network server C terminal connection), and Xargument is the first three characters of the C command verb followed by the rest of the user's command line. (Some tasks C parse out the command verb from the invoking MCR line, so we have to let C them find a command verb to parse out. In order to limit the amount by C which we increase the user's original command line length, the command verb C is shortened to the first three characters of the task's name.) If all this C results in the command line exceeding 80. characters, the user gets a C message to that effect. write(filenm,800)cmd(:cmdl) 800 format('LB:[1,54]',a,'.TSK') ifl=cmdl+13 c--see if the task file exists in LB:[1,54] c--turn off no-such-file msg and inconsistent-record-length msg call errset(29,.true.,.false.,.true.,.false.) call errset(37,.true.,.false.,.true.,.false.) call errsns !clear any previous errors open(unit=1,file=filenm,status='old',readonly,err=805) goto 810 c--check the FCS error number... 805 call errsns(ierr,ifcs,ifcs1) if(ierr.ne.37)goto 820 !if any other error #, its not there c--file exists: change the LB:[1,54] to $ 810 write(filenm,811)filenm(10:) 811 format('$',a) ifl=cmdl+5 goto 830 c--no such file under LB:[1,54] - try LB:[2,54] 820 filenm(5:5)='2' open(unit=1,file=filenm,status='old',readonly,err=825) goto 830 c--check the FCS error number... 825 call errsns(ierr,ifcs,ifcs1) if(ierr.ne.37)goto 860 !if any other error #, its not there c--make MCR command line to RUN the task file, with the command line C *NOTE* - user commands can jump here with: C - name of task file in FILENM (with device, UIC or $, etc) C - length of task file name in IFL (including .TSK portion) C - first 3 letters of desired installed task name in CMD C - length of desired (length of string in CMD) in CMDL C - command line (if any) in ARG C - length of command line in ARGL 830 i=min(3,cmdl) j=2 if(param(2).lt."10)j=1 write(spwnln,835)filenm(:ifl-4),cmd(:i),param(1),param(2) 835 format('RUN ',a,'/TASK=',a,a1,o.) n=ifl+j+10 c--add rest of user's command line, if any, as command to spawned task D write(2,846)n,spwnln(:n) if(argl.le.0)goto 900 write(spwnln(n+1:),845)cmd(:i),arg(:argl) 845 format('/CMD="',a,a,'"') n=n+argl+i+7 D write(2,846)n,spwnln(:n) D846 format(' n=',i2,'*',a,'*') goto 900 C--see if there's a command file with the same name as the command verb C in the default account of LB:[2,24] C if there is, execute it with the command line C @LB:[2,24]command argument 860 filenm(5:8)='2,24' filenm(ifl-2:ifl)='CMD' open(unit=1,file=filenm,status='old',readonly,err=890) C--found it - spawn "@filenm arg" 880 write(spwnln,881)filenm(:ifl-4),cr 881 format('@',a,a1) n=ifl-2 if(argl.le.0)goto 900 write(spwnln(n:),885)arg(:argl),cr 885 format(a,a1) n=n+argl goto 900 C--fell thru to here - send msg (same as MCR msg) to user then exit 890 write(2,895) 895 format(' MCR -- Task not in system') goto 999 C--spawn MCR to handle new command C all commands should come here to spawn MCR with a new command line C with the command in SPWNLN(1:n), and the number of characters in C the new command line in 'n'. C--make sure the new MCR command is not too long 900 if(n.le.78)goto 920 write(2,910) 910 format(' line too long') goto 999 920 flgbyt=130 C--if this program is compiled with diagnostic code, write the spawned command C line to the user's terminal, then exit. If not, go on and spawn the command D write(2,930)n,spwnln(:n) D930 format(' diag - spawned command line (',i2,' characters in cmd line):'/ D +' *',a,'*') D goto 999 C--spawn RPOI and exit call rpoi(mcr,,,,spwnln,n,flgbyt,param(1),param(2)) 999 call exit end