.; COMPILE.CMD		V1.2	5-Sept-85
.;
.; Author: C J Doran, Sira Ltd., South Hill, Chislehurst, Kent, BR7 5EH, England
.;	   Tel: +44 1 467 2636,    Telex: 896649,	Fax: +44 1 467 6515
.;
.; Helps compile, load and run programs written in any of a number of defined
.; languages.  The command file just loops round, asking you to enter name(s)
.; of modules to be edited and recompiled.  See help text for more details.
.;
.; This file must be entered in the directory under the name of each language
.; it is to be used for, as:
.;	>PIP FORTRAN.CMD/EN=COMPILE.CMD		etc.
.;
.; NOTE: This file is heavily customised for the Sira system. If using elsewhere,
.;	 see subroutine INIT (end) for some default settings.
.;
	.GOSUB INIT COMMAN
.GET:	.IF P1 <> "" .GOTO GOT
.MORE:
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASKS [:::30S] P0 Files to '$CMPAS':'CR%V''LF%V'>* [. = '$DEFIL']
	.IF P0 = "" .GOTO BUILD
	.SETS P1 ""
	.SETS P2 ""
	.SETS P3 ""
	.SETS P4 ""
	.SETS P5 ""
	.SETS P6 ""
	.SETS P7 ""
	.SETS P8 ""
	.SETS P9 ""
	.PARSE P0 " " P1 P2 P3 P4 P5 P6 P7 P8 P9
.GOT:	.SETN N 1.
.LOOP:
	.SETS P1 P'N'
	.IF P1 = "" .GOTO BUILD
	.IF P1 = "+" .GOTO MORE
	.IF P1 = "/" .GOTO FINISH
	.IF P1 = "//" .GOTO DONE
	.IF P1 = "<" .GOTO CMPRS
	.GOSUB COMPIL
	.IFF FILOPN .OR .IFT LIBRY .OR .IF P1 = $TASK .GOTO NEXTN
	.IF $TKB <> "LD1" .DATA 'P1'.'$OBTYP''$CONMK'
	.IF $TKB = "LD1" .DATA 'P1'
.NEXTN:
	.INC N
	.IF N = 10. .GOTO MORE
	.GOTO LOOP
.CMPRS:	.IFF LIBRY .OR .IF $LIBR <> "LBR" .GOTO NEXTN
	LBR '$TASK'/CO:10.='$TASK'
	.IF <EXSTAT> = 1 PIP '$TASK'.OLB/PU
	.GOTO NEXTN
.BUILD:
	.GOSUB '$TKB'BLD
	.IFT FAILED .GOTO EDITS
.RUN:
	.IFF $MCR SET /CLI=TI:'$CLI'
	.TESTFILE 'TSKRUN'
	.IF <FILERR> <> 1 .GOTO JSTRUN
	@'TSKRUN'
	.GOTO AGAIN
.JSTRUN: '$RUN''$TASK'
	.IF $RUN = "; " .GOTO AGAIN
	.ENABLE LOWERCASE
	.SETS TEMP "unknown"
	.IF <EXSTAT> = 0 .SETS TEMP "warning"
	.IF <EXSTAT> = 1 .SETS TEMP "success"
	.IF <EXSTAT> = 2 .SETS TEMP "error"
	.IF <EXSTAT> = 4 .SETS TEMP "severe error"
	; Task exited with 'TEMP' status (code = '<EXSTAT>')
.AGAIN:
	.ENABLE LOWERCASE
	.GOSUB QUEST1 .ASK YN Run again
	.IFT YN .GOTO RUN
.EDITS:
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASKS P1 Edit file [. = '$DEFIL']
	.IF P1 = "//" .GOTO DONE
	.IF P1 = "/" .GOTO FINISH
	.IF P1 = "" .GOTO MORE
	.PARSE P1 "/" P1 LIST
	.IF P1 = "." .SETS P1 $DEFIL
	.PARSE P1 "." P1 TEMP
	.SETS $DEFIL P1
	.GOSUB EDIT
	.GOTO EDITS
.;
.FINISH: .ENABLE LOWERCASE
	.IFT FILOPN .CLOSE
	.IFT FILOPN PIP '$SP''TSKBLD'.TMP;*/DE/NM
	.GOSUB QUESTN .ASK [:20S] YN Purge *.'$FTYPE'
	.IFT <TIMOUT> .GOTO DONE
	.IFT YN PIP *.'$FTYPE'/PU/LD/NM
	; Selective delete of '$TASK'.'$TKTYP',.MAP,.STB,.'$OBTYP','TSKBLD'.CMD
	; Answer Q to first question to quit deleting.
	PIP 'TSKBLD'.CMD;*/SD/NM,'$TASK'.STB;*,.'$OBTYP';*,TK:.'$TKTYP';*,MP:.MAP;*
	.IF $CLEAN <> "" PIP '$CLEAN'
.DONE:	.IFF $MCR SET /CLI=TI:'$CLI'
.QUIT:	.EXIT
.;
.COMPIL:
	.PARSE P1 "/" P1 LIST
	.IF P1 = "." .SETS P1 $DEFIL
	.PARSE P1 "." P1 TEMP
	.SETS $DEFIL P1
	.IF $TASK <> "" .GOTO TSTLST
	.SETS $TASK P1
	.IF $MICRO = "68" .SETS $HEXSW $HEXSW+$TASK
	.TESTFILE '$TASK'.'$LBTYP'
	.IF <FILERR> = 1 .SETT LIBRY
	.IFT LIBRY .AND .IF $TKB = "FTB" .SETS $TKB "TKB"
	.SETS P0 $TASK[1:6]
	.SETS TSKBLD P0+"BLD"
	.SETS TSKASM P0+"ASM.CMD"
	.SETS TSKRUN P0+"RUN.CMD"
	.TESTFILE 'TSKBLD'.CMD
	.IF <FILERR> = 1 .GOTO TSTLST
	.IF $LANG <> "MAC" .AND .IF $LANG <> "MAR" .GOTO NOTODT
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Build with ODT
	.IFF YN .GOTO NOTODT
	.SETS $ODT "/DA"
	.SETS $TKB "TKB"
	.SETS TEMP $TASK[1:6]
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Enable EMTs
	.IFT YN .SETS $TKOP1 "GBLPAT='TEMP':.ODTL1-14:0"
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Enable IOTs
	.IFT YN .SETS $TKOP2 "GBLPAT='TEMP':.ODTL1-20:0"
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Start without user intervention
	.IFT YN .SETS $TKOP3 "GBLPAT='TEMP':.ODTL1+706:240"
.NOTODT: .IF $FDB <> "" .SETS $STB ",SY:'$TASK'"
	.SETT FILOPN
	.OPEN '$SP''TSKBLD'.TMP
	.IF $TKB = "LKR" .GOTO STALIN
	.IF $TKB = "LD1" .DATA '$TASK'
	.IF $TKB = "LD1" .GOTO TSTLST
	.DATA TK:'$TASK''$ODT',MP:'$TASK'/-SP'$STB'='$DEBUG'
	.IFF LIBRY .DATA '$TASK'
	.IFT LIBRY .DATA '$TASK'/LB:'$TASK','$TASK'/LB
	.GOTO TSTLST
.STALIN: .DATA -ET__TEXT -ED__EDATA -EB__MEMORY -
	.DATA -ST__STEXT -SD__SDATA -SB__SBSS -
	.DATA -OTK:XEQ. LB:[1,1]CRTCPM.'$LBTYP''$CONMK'
	.IFF LIBRY .DATA '$TASK'.'$OBTYP''$CONMK'
	.IFT LIBRY .DATA '$TASK'.'$LBTYP''$CONMK'
.TSTLST:
	.IF LIST = "NC" .RETURN
.COMP:
	.SETS OUT P1
	.SETS TEMP LIST
	.SETS LIST ""
	.IF TEMP = "LO" .OR .IF TEMP = "PO" .SETS OUT ""
	.IF TEMP = "PR" .OR .IF TEMP = "PO" .SETS LIST ",'$SP''P1'/-SP"
	.IF TEMP = "LI" .OR .IF TEMP = "LO" .SETS LIST ",'$SP''P1'/SP"
	.GOSUB '$CMPIL'
	.IFF FAILED .GOTO COMPOK
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [<TRUE>] YN Edit
	.IFF YN .GOTO EXCOMP
.EDIT:
	.IF $EDITR <> "" .GOTO ED1
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASKS [3:3:"EDT"] $EDITR Editor name (EDI, EDT, TEC etc.)
	.IF $EDITR <> "EDT" .SETS $EDINI ""
.ED1:
	.TESTFILE 'P1'.'$FTYPE'
	.PARSE <FILSPC> ";" TEMP2 TEMP
	'$EDITR' 'P1'.'$FTYPE''$EDINI'
	.TESTFILE 'P1'.'$FTYPE'
	.PARSE <FILSPC> ";" TEMP2 TEMP1
	.IF TEMP = TEMP1 .GOTO EXCOMP
	.IF TEMP = "0" .GOTO ED2
	.SETS TEMP1 TEMP2+";"+TEMP
	.TESTFILE 'TEMP1'
	.IF <FILERR> <> 1 .GOTO ED2
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Delete old file 'TEMP1'
	.IFT YN PIP 'TEMP1'/DE
.ED2:
	.SETT YN
	.ENABLE LOWERCASE
	.IF LIST <> "" .GOSUB QUESTN .ASK [<TRUE>:20S] YN Do you need to re-list
	.IFF YN .SETS LIST ""
	.GOTO COMP
.COMPOK:
	.IF OUT = "" .GOTO EXCOMP
.DELOBJ:
	.IFF LIBRY .GOTO KEEPOB
	.IF $LIBR = "LBR" LBR '$TASK'/RP='OUT'.'$OBTYP'
	.IF $LIBR = "LBY" LBY '$TASK'.'$LBTYP' -R 'OUT'.'$OBTYP'
	.IF $LIBR = "LBY" PIP '$TASK'.'$LBTYP'/PU
	PIP 'OUT'.'$OBTYP';*/DE
	.RETURN
.KEEPOB:
	PIP 'OUT'.'$OBTYP'/PU
	.IF $OBTYP = "BIN" PIP 'OUT'.LNK/PU
.EXCOMP:
	.RETURN
.;
.; Ask question. If answer is escape, allow commands to be passed repeatedly
.; to CLI, with edit facility! On blank CLI line, return to repeat question.
.; = repeats last command, - edits it, / exits command file with cleanup,
.; // exits without.
.QUEST1: .IFF $MCR MCR SET /MCR=TI:
.QUESTN:
	.DISABLE LOWERCASE
	'COMMAN'
	.IFF <ESCAPE> .RETURN
	.SETS LSTCMD ""
	.IFF $MCR SET /CLI=TI:'$CLI'
	.ENABLE LOWERCASE
.MCR:
	.DISABLE DISPLAY
	.ASKS COMAND '<CLI>'>
	.ENABLE DISPLAY
	.IFF <ESCAPE> .GOTO NOTPAU
	  .PAUSE
	  .GOTO MCR
.NOTPAU: .IF COMAND = "" .GOTO QUEST1
	.IF COMAND = "//" .GOTO QUIT
	.IF COMAND <> "/" .GOTO NOTEND
	  .IFF $MCR MCR SET /MCR=TI:
	  .GOTO FINISH
.NOTEND: .IF COMAND = "-" .GOTO EDICMD
	.IF COMAND = "=" .SETS COMAND LSTCMD
.XQTMCR: .SETS LSTCMD COMAND[1:1]
	.IF LSTCMD <> "." .GOTO NOTDOT
	.SETS COMAND COMAND[2:*]
	.IF <CLI> <> "MCR" .SETS COMAND "MCR "+COMAND
.NOTDOT:.SETS LSTCMD COMAND
	.ENABLE QUIET
	'COMAND'
	.DISABLE QUIET
	.GOTO MCR
.EDICMD: .SETS COMAND LSTCMD
.CHANGE:
	.IF COMAND = "" .GOTO MCR
	; >'COMAND'
	.ASKS OLD Change first (CR to execute)
	.IFT <DEFAUL> .GOTO XQTMCR
	.TEST COMAND OLD
	.IF <STRLEN> = 0 .GOTO CHANGE
	.SETN I <STRLEN>
	.ASKS NEW to
	.TEST OLD
	.SETS COMAND COMAND[1:I-1]+NEW+COMAND[I+<STRLEN>:*]
	.GOTO CHANGE
.; COMPILE FILE
.; ************
.;
.; Language-dependent compilation subroutines, selected by $CMPIL.
.; Enter with:-
.;	P1	filename (without filetype)
.;	LIST	null or ,'$SP'P1/SP or ,'$SP'P1/-SP
.;	OUT	null or P1
.; Exit with:-
.;	FAILED	set TRUE or FALSE
 
.; MACRO-11
.; If file 'TSKASM' exists, search it to see if there is a command file
.; to assemble this file, which may include prefix file names.
.ASMMAC:
	.SETS RHS P1
	.TESTFILE 'TSKASM'
	.IF <FILERR> <> 1 .GOTO ASMMC
	.OPENR #2 'TSKASM'
.SEARCH:
	.SETS RHS P1
	.IFT <EOF> .GOTO CLS
	.READ #2 ASMCMD
	.PARSE ASMCMD "=" LHS RHS
	.IF LHS = P1 .GOTO CLS
	.IF LHS <> "*" .GOTO SEARCH
	.TEST RHS "*"
	.IF <STRLEN> <> 0 .SETS RHS RHS[1:<STRLEN>-1]+P1+RHS[<STRLEN>+1:*]
.CLS:	.CLOSE #2
.ASMMC:	.IF OUT = "" .SETS OUT "NL:"
	'$LANG' 'OUT''LIST'='RHS'
	.SETF FAILED
	.IF <EXSTAT> <> 1 .SETT FAILED
	.IFACT CRF... .WAIT CRF...
	.IF LIST = ",'$SP''P1'/-SP" PRI LP0:='$SP''P1'
	.IF OUT = "NL:" .SETS OUT ""
	.RETURN
 
.; RMCS CORAL-66 or BCPL.
.CPLCOR:
	.SETS RHS P1+$CORSW
	.SETT FAILED
	.IF $LANG = "COR" .AND .IF LIST <> "" .SETS RHS RHS+"Q"
	.IF $LANG = "BPL" .AND .IF LIST <> "" .GOSUB LISTN
	.IF OUT = "" .SETS RHS RHS+"C"
	.IF OUT <> "" .SETS RHS RHS+$COCSW
	.IF OUT = "" .SETS OUT "NL:"
	'$LANG' 'OUT'='RHS'
	.IF LIST = ",'$SP''P1'/-SP" QUE CORAL/DEL
	.IF LIST = ",'$SP''P1'/-SP" PRI LP0:=CORAL
	.IF OUT = "NL:" .GOTO DELOCD
	.IFACT '$COGEN' .GOTO EXCOR
.DELOCD: PIP TEMP.OCD;*/DE/NM
	.IF OUT <> "NL:" .RETURN
	.SETS OUT ""
	.SETF FAILED
	.RETURN
.EXCOR:	.;	.WAIT '$COGEN'		!BUG -- NOT WORKING!
	.ENABLE QUIET
	.DELAY 1S
	.DISABLE QUIET
	.IFACT '$COGEN' .GOTO EXCOR
	.SETF FAILED
	.RETURN
 
.; Standard case.
.STDCPL:
	'$LANG' 'OUT''LIST'='P1''$FDB'
	.SETF FAILED
	.IF <EXSTAT> <> 1 .SETT FAILED
	.IF LIST = ",'$SP''P1'/-SP" PRI LP0:='$SP''P1'
	.RETURN
 
.; Compile RATFOR.
.CPLRAT:
	RAT '$SP''P1'.FIV'LIST'='P1'/-GO
	.SETF FAILED
	.IF <EXSTAT> <> 1 .SETT FAILED
	.IF LIST = ",'$SP''P1'/-SP" PRI LP0:='$SP''P1'
	.IFT FAILED .RETURN
	'$LANG' 'OUT'='$SP''P1'.FIV'$FDB'
	.IF <EXSTAT> <> 1 .SETT FAILED
	.IFF FAILED PIP '$SP''P1'.FIV;0/DE/NM
	.RETURN
	
.; Whitesmith's Pascal and C for PDP-11
.CPLP11:
	.GOSUB CPTC
	.IFT FAILED .OR .IF OUT = "" .RETURN
.CPLC11:
	.GOSUB CPLC
	.IFT FAILED .OR .IF OUT = "" .RETURN
	.SETT FAILED
	PIP '$SP''P1'.PAL;*/DE/NM
	CP2 -FO '$SP''P1'.PAL '$SP''P1'.CP2!'BS%V' 'LF%V'
	.IF <EXSTAT> <> 1 .RETURN
	MAC 'P1'='$SP''P1'.PAL
	.IF <EXSTAT> = 1 .SETF FAILED
	.RETURN
 
.; Whitesmith's Pascal/C for 8080 and 68000.
.CPLPUP:
	.GOSUB CPTC
	.IFT FAILED .OR .IF OUT = "" .RETURN
.CPLCUP:
	.GOSUB CPLC
	.IFT FAILED .OR .IF OUT = "" .RETURN
	.SETT FAILED
	PIP '$SP''P1'.A'$MICRO';*/DE/NM
	P'$MICRO' -O '$SP''P1'.A'$MICRO' '$SP''P1'.CP2!'BS%V' 'LF%V'
	.IF <EXSTAT> <> 1 .RETURN
	A'$MICRO' -O 'P1'.'$OBTYP' '$SP''P1'.A'$MICRO'!'BS%V' 'LF%V'
	.IF <EXSTAT> = 1 .SETF FAILED
	.RETURN
 
.; Pascal/C initial compilations common to PDP-11, 8080, and 68000.
.CPTC:
	.SETF FAILED
	.IF LIST <> "" .GOSUB LISTN
	.IF OUT = "" .RETURN
	PIP 'P1'.PTC;*/DE/NM
	PTC <'P1'.PAS >'P1'.PTC!'BS%V' 'LF%V'
	.IF <EXSTAT> <> 1 .SETT FAILED
	.RETURN
 
.CPLC:
	.SETF FAILED
	.IF LIST <> "" .AND .IF $FTYPE = "C" .GOSUB LISTN
	.IF OUT = "" .RETURN
	.SETT FAILED
	PIP '$SP''P1'.CP1;*/DE/NM,'P1'.CP2;*
	CPP -X -I LB:[1,1] -O '$SP''P1'.CP1 'P1'.'$CINTP'!'BS%V' 'LF%V'
	.IF <EXSTAT> <> 1 .RETURN
	CP1 '$CP1SW' -M -O '$SP''P1'.CP2 '$SP''P1'.CP1!'BS%V' 'LF%V'
	.IF <EXSTAT> = 1 .SETF FAILED
	.RETURN
 
 
.; BUILD TASK
.; **********
.;
.; Subroutines to use FTB/TKB or LKR to do the task-build.
.; Enter with:-
.;	$TASK	Task name
.; Exit with:-
.;	FAILED	set TRUE or FALSE
 
.; Build task using DEC task-builder, TKB or FTB.
.FTBBLD:
.TKBBLD:
	.IFF FILOPN .GOTO BUILDD
	.GOSUB ASKLB
	.DATA /
	.IF $FCSRS <> "" .DATA '$FCSRS'
	.IF $TKOP1 <> "" .DATA '$TKOP1'
	.IF $TKOP2 <> "" .DATA '$TKOP2'
	.IF $TKOP3 <> "" .DATA '$TKOP3'
	.IF $TKOP4 <> "" .DATA '$TKOP4'
	.IF $TKOP5 <> "" .DATA '$TKOP5'
	.IF P0 = "/" .GOTO ENDOPT
	;
	; Enter any special '$TKB' options.  End with a blank line.
	;
	; Defaults are:
	.IF $FCSRS <> "" ;	'$FCSRS'
	.IF $TKOP1 <> "" ;	'$TKOP1'
	.IF $TKOP2 <> "" ;	'$TKOP2'
	.IF $TKOP3 <> "" ;	'$TKOP3'
	.IF $TKOP4 <> "" ;	'$TKOP4'
	.IF $TKOP5 <> "" ;	'$TKOP5'
	;
.OPT:	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASKS [:::20S] P0 Option
	.IF P0 = "" .OR .IF P0 = "/" .GOTO ENDOPT
	.DATA 'P0'
	.IF $TKB = "TKB" .GOTO OPT
.; If FTB in use, make sure this option is supported
	.PARSE P0 "=" P0 TEMP
	.TEST "ASG,STACK,UNITS,EXTSCT,ACTFIL,MAXBUF" P0
	.IF <STRLEN> <> 0 .GOTO OPT
	.TEST "LIBR,COMMON,RESLIB,RESCOM,SUPLIB,RESSUP" P0
	.IF <STRLEN> <> 0 .GOTO OPT
	.SETS $TKB "TKB"
	.GOTO OPT
.ENDOPT: .DATA //
	.GOSUB ELFILE
.BUILDD:
	PIP TK:'$TASK'.TSK;*/DE/NM,MP:'$TASK'.MAP;*,SY:'$TASK'.STB;*
	'$TKB' @'TSKBLD'
	.SETF FAILED
	.IF <EXSTAT> <> 1 .SETT FAILED
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Type map file
	.IFF YN .GOTO NOTMAP
	.IFACT CRF... .WAIT CRF...
	LIST TI:=MP:'$TASK'.MAP/PA/CO:1/NH
.NOTMAP:
	.IFF FAILED .RETURN
	.IF $TKB <> "FTB" .RETURN
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [<TRUE>:20S] YN Try TKB instead
	.SETT FAILED
	.IFF YN .RETURN
.TRYTKB: .SETS $TKB "TKB"
	.GOTO BUILDD
 
.; Task-build for 8080 and 68000 Pascal or C.
.LKRBLD:
	.IFF FILOPN .GOTO BUILDL
	.GOSUB ASKLB
	.GOSUB ELFILE
.BUILDL:
	PIP MP:'$TASK'.MAP;*/DE/NM,TK:'$TASK'.LDA;*,XEQ.;*
	.SETT FAILED
	LKR @'TSKBLD'!'BS%V' 'LF%V'
	.IF <EXSTAT> <> 1 .RETURN
	REL -DSTUV >MP:'$TASK'.MAP TK:XEQ.!'BS%V' 'LF%V'
	.IF <EXSTAT> <> 1 .RETURN
	HEX '$HEXSW' >TK:'$TASK'.LDA TK:XEQ.!'BS%V' 'LF%V'
	.IF <EXSTAT> <> 0 .SETF FAILED
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Type map file
	.IFT YN LIST TI:=MP:'$TASK'.MAP/NH/PA/BS
	.RETURN
 

.; Dummy task-build for CORAL/BCPL programs run with LD1. Just complete link
.; command file.
.LD1BLD:
	.SETF FAILED
	.IFF FILOPN .RETURN
	; Name any files you have already compiled and which have NOT been named
	; above. End with a blank line.
	;
.LFILE:
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASKS [:::20S] P0 Files (separated by COMMAS)
	.IF P0 = "" .OR .IF P0 = "/" .GOTO ELFILE
	.DATA 'P0'
	.GOTO LFILE
.; Close temporary build file, copy to SY: renaming .CMD, and delete.
.; This code is also called as a subroutine.
.ELFILE: .CLOSE
	.SETF FILOPN
	PIP 'TSKBLD'.CMD='$SP''TSKBLD'.TMP
	PIP '$SP''TSKBLD'.TMP;*/DE/NM
	.RETURN

.; Unless NL is defined already, ask whether numerical, cursor control, string
.; and/or plotter libraries are required (if they exist). The libraries are
.; available only if $NUMLB, $PLOLB, $VTLIB, $UNXLB, and $STRLB are non-null,
.; respectively. Put library names into build command file if required.
.ASKLB:
	; ** SETTING UP BUILD COMMAND FILE **
	;
	.IF $LANG <> "F77" .GOTO NOVIRT
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Are you using VIRTUAL arrays
	.IFF YN .AND .IFT FILOPN .DATA LB:[11,40]NOVIRT
	.IFT YN .SETS $TKB "TKB"
	;
.NOVIRT: ; Name any object files or libraries you have already '$CMPAS'd,
	; and which have NOT been named above. End with a blank line.
	.IF $TKB <> "LKR" ; Libraries MUST have a /LB switch.
	.IF $TKB = "LKR" ; You MUST give filetypes -- .'$OBTYP' for objects, .'$LBTYP' for libraries.
	;
.FILE:
	.ENABLE LOWERCASE
	.IF $TKB <> "LKR" .GOSUB QUESTN .ASKS [:::20S] P0 Files (separated by COMMAS)
	.IF $TKB = "LKR" .GOSUB QUESTN .ASKS [:::20S] P0 Files (separated by SPACES)
	.IF P0 = "" .GOTO LIBS
	.IF P0 = "/" .GOTO ENDLIB
	.DATA 'P0''$CONMK'
	.GOTO FILE
.LIBS:	.IFDF NL .GOTO ENDLIB
	.SETF NL
	.IF $NUMLB = "" .GOTO PLOLIB
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Do you need the Numerical Library
	.IFT YN .DATA '$NUMLB''$CONMK'
.PLOLIB: .IF $PLOLB = "" .GOTO VTLIB
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Do you need the Plotter Library
	.IFT YN .DATA '$PLOLB''$CONMK'
.VTLIB:	.IF $VTLIB = "" .GOTO STRLIB
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Do you need the Screen Cursor-control Library
	.IFF YN .GOTO STRLIB
	.DATA '$VTLIB''$CONMK'
	.IF $LANG = "F77" .OR .IF $LANG = "F7D" .GOTO ENDLIB
.STRLIB: .IF $STRLB = "" .GOTO UNXLIB
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Do you need the RATFOR String Library
	.IFT YN .DATA '$STRLB''$CONMK'
.UNXLIB: .IF $UNXLB = "" .GOTO ENDLIB
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Do you need the Unix-compatible Library
	.IFT YN .DATA '$UNXLB''$CONMK'
.ENDLIB:.IF $OTSLB <> "" .DATA '$OTSLB'
	.RETURN
 
 
.; List source file for those compilers which don't have a listing facility.
.LISTN:
	.IF $FTYPE <> "C" LIST '$SP''P1'/-SP='P1'.'$FTYPE'/CO:1/LN
	.IF $FTYPE = "C" CLT 'P1'.C >'$SP''P1'
	.IF LIST = ",'$SP''P1'/-SP" PRI LP0:='$SP''P1'/NM
	.IF LIST = ",'$SP''P1'/SP" PRI '$SP''P1'/NM
	.RETURN
.;
.; Initialisation code. Put here as a subroutine to speed up later label
.; searches (which presumably start from the top of the file).
.;
.; First set up defaults.
.INIT:	.ENABLE SUBSTITUTION
	.ENABLE ESCAPE
	.SETS $SP ""
.;	.SETS $SP "SP:"
	.SETN CR 15
	.SETN LF 12
	.SETN BS 10
	.SETF FILOPN
	.SETS $DEFIL "TEST"
	.SETS TSKBLD ""
	.SETF LIBRY
	.SETS $CP1SW ""
	.SETS $HEXSW ""
	.SETS $TKB "FTB"
	.SETS $FCSRS ""
.;	.SETS $FCSRS "LIBR=FCSRES:RO"
	.SETS $FCSRS "SUPLIB=FCSFSL:SV"
	.SETS $TKOP1 ""
	.SETS $TKOP2 ""
	.SETS $TKOP3 ""
	.SETS $TKOP4 ""
	.SETS $TKOP5 ""
	.SETS $RUN "RUN TK:"
	.SETS $CMPIL "STDCPL"
	.SETS $TKTYP "TSK"
	.SETS $LIBR "LBR"
	.SETS $LBTYP "OLB"
	.SETS $EDINI ""
	.SETS $CMPAS "compile"
	.SETS $OBTYP "OBJ"
	.SETS $TASK ""
	.SETS $OTSLB ""
	.SETS $NUMLB ""
	.SETS $PLOLB ""
	.SETS $VTLIB ""
	.SETS $STRLB ""
	.SETS $UNXLB ""
	.SETS $ODT ""
	.SETS $MICRO ""
	.SETS $CONMK ""
	.SETS $CINTP ""
	.SETS $CORSW "/"
	.SETS $COGEN ""
	.SETS $DEBUG ""
	.SETS $FDB ""
	.SETS $STB ""
	.SETT $MCR
	.SETS $CLEAN ""
	.IF <CLI> <> "MCR" .SETF $MCR
	.SETS $CLI <CLI>
	.IFF $MCR MCR SET /MCR=TI:
	.PARSE <UIC> "[,]" TEMP G M TEMP
	.SETN NG 'G'
	.SETN NM 'M'
	.SETS TEMP "[0,0]'NG%ZR3''NM%ZR3'.DIR"
	.IF $SP <> "" .TESTFILE '$SP''TEMP'
	.IF $SP <> "" .AND .IF <FILERR> <> 1 ASN SY:=SP:
	.TESTFILE TK:'TEMP'
	.IF <FILERR> <> 1 ASN SY:=TK:
	.TESTFILE MP:'TEMP'
	.IF <FILERR> <> 1 ASN SY:=MP:
.; Find out which language this is from our command file name, given in P0.
.; Must strip off any disk/directory specification and switches.
	.PARSE P0 ":" COMMAN P0
	.IF P0 = "" .SETS P0 COMMAN
	.PARSE P0 "]" COMMAN P0
	.IF P0 = "" .SETS P0 COMMAN
	.PARSE P0 "/" P0 COMMAN
	.SETS $LANG P0[1:3]
	.IF $LANG = "BCP" .SETS $LANG "BPL"
	.SETS $FTYPE $LANG
	.IF $LANG = "COR" .SETS $FTYPE "CRL"
.; Make sure language is one we know about, and set language-dependent symbols.
	.IF P0 <> "FORTRAN" .GOTO TRYCOR
	.SETS $NUMLB "LY:[200,201]FNL/LB"
	.GOTO COMFOR
.TRYCOR: .IF P0 <> "CORAL" .GOTO TRYC80
	.SETS $OTSLB "LB:[1,1]CORLIB/LB"
	.SETS $NUMLB "LY:[200,201]CNL/LB"
	.SETS $CORSW "/"
	.SETS $COCSW "Y:QA"
	.SETS $EDINI ",LY:[200,203]CORAL"
	.SETS $COGEN "COC"
	.GOTO COMCOR
.TRYC80: .IF P0 <> "C80" .GOTO TRYC11
	.SETS $CMPIL "CPLCUP"
	.SETS $CP1SW "-B0 -N8 -U"
	.SETS $FTYPE "C"
	.SETS $CINTP "C"
	.SETS $UNXLB "LB:[1,1]LBUCPM.80"
	.SETS $EDINI ",LY:[200,203]C"
	.GOTO COM80
.TRYC11: .IF P0 <> "C11" .GOTO TRYMAC
	.SETS $CMPIL "CPLC11"
	.SETS $FTYPE "C"
	.SETS $CINTP "C"
	.SETS $CP1SW "-CN6"
	.SETS $UNXLB "LB:[1,1]ULIB/LB"
	.SETS $EDINI ",LY:[200,203]C"
	.GOTO COMC11
.TRYMAC: .IF P0 <> "MACRO" .AND .IF P0 <> "MAR" .GOTO TRYCRD
	.SETS $CMPIL "ASMMAC"
	.SETS $CMPAS "assemble"
	.SETS $EDINI ",LY:[200,203]"+P0
	.GOTO HELP
.TRYCRD: .IF P0 <> "CORALD" .GOTO TRYFD
	.SETS $NUMLB "LY:[200,201]CNLD/LB,CNL/LB"
	.SETS $COCSW "YD:QA"
	.SETS $EDINI ",LY:[200,203]CORAL"
	.GOTO COMCOR
.TRYFD: .IF P0 <> "FORTRAND" .GOTO TRYCOK
	.SETS $NUMLB "LY:[200,201]FNLD/LB"
.COMFOR: .SETS $OTSLB "LB:[1,1]F77OTS/LB"
	.SETS $FTYPE "FTN"
	.GOTO CMRTF7
.TRYCOK: .IF P0 <> "CORALK" .GOTO TRYCKD
	.SETS $NUMLB "LY:[200,201]CNL/LB"
	.SETS $CORSW "/K"
	.GOTO COMCKE
.TRYCKD: .IF P0 <> "CORALKD" .GOTO TRYPAS
	.SETS $NUMLB "LY:[200,201]CNLD/LB,CNL/LB"
	.SETS $CORSW "/KD"
.COMCKE:.SETS $COCSW "Y:QA"
	.SETS $EDINI ",LY:[200,203]CORALK"
.COMCOR: .SETS $CMPIL "CPLCOR"
	.SETS $OTSLB "LB:[1,1]CORLIB/LB"
	.SETS $PLOLB "LY:[200,201]CPLOT/LB"
	.SETS $TKOP1 "STACK=48"
	.SETS $COGEN "COC"
	.SETS $CLEAN "TEMP.OCD;*/DE/NM,*.PAL;*"
	.GOTO HELP
.TRYPAS: .IF P0 <> "PASCAL" .GOTO TRYP80
	.SETS $LANG "P11"
	.SETS $CINTP "PTC"
	.SETS $CMPIL "CPLP11"
	.SETS $CP1SW "-CE"
	.SETS $EDINI ",LY:[200,203]PASCAL"
	.SETS $CLEAN "*.PTC;*/DE/NM"
.COMC11:.SETS $OTSLB "LB:[1,1]CHDR,CLIB/LB"
	.SETS $NUMLB "LY:[200,201]C11NL/LB"
.;	.SETS $PLOLB "LY:[200,201]C11PLOT/LB"
	.SETS $TKOP1 "STACK=3000"
	.SETS $TKOP2 "UNITS=12"
	.SETS $TKOP3 "ACTFIL=11"
	.SETS $TKOP4 "ASG=SY:1:2:3:4,TI:5"
	.SETS $TKOP5 "ASG=SY:6:7:8:9:10:11:12"
	.IF $CLEAN <> "" .SETS $CLEAN $CLEAN+","
	.SETS $CLEAN $CLEAN+"*.CP1;*/DE/NM,*.CP2;*,*.PAL;*,CTEMPC.1;*"
	.GOTO HELP
.TRYP80: .IF P0 <> "PASCAL80" .GOTO TRYBCP
	.SETS $LANG "P80"
	.SETS $CINTP "PTC"
	.SETS $CMPIL "CPLPUP"
	.SETS $CP1SW "-CE"
	.SETS $EDINI ",LY:[200,203]PASCAL"
	.SETS $CLEAN "*.PTC;*/DE/NM"
.COM80:	.SETS $MICRO "80"
	.SETS $LBTYP "80"
	.SETS $HEXSW "-H"
	.SETS $RUN "; "
.;	.SETS $NUMLB "LY:[200,201]CNL.80"
.;	.SETS $PLOLB "LY:[200,201]CPLOT.80"
	.GOTO COMUP
.TRYBCP: .IF P0 <> "BCPL" .GOTO TRYC68
	.SETS $OTSLB "LB:[1,1]CORLIB/LB:BCPL,CORLIB/LB"
	.SETS $NUMLB "LY:[200,201]CNL/LB"
	.SETS $COCSW "Y:DT390A"
	.SETS $TKB "TKB"
	.SETS $COGEN "COC"
	.GOTO HELP
.TRYC68: .IF P0 <> "C68K" .GOTO TRYP68
	.SETS $CMPIL "CPLCUP"
	.SETS $CP1SW "-AL -N8 -U"
	.SETS $FTYPE "C"
	.SETS $CINTP "C"
	.SETS $EDINI ",LY:[200,203]C"
	.SETS $UNXLB "LB:[1,1]LBUCPM.68K"
	.GOTO COM68K
.TRYP68: .IF P0 <> "PASCAL68K" .GOTO TRYLD1
	.SETS $LANG "P68"
	.SETS $CINTP "PTC"
	.SETS $CMPIL "CPLPUP"
	.SETS $CP1SW "-CE"
	.SETS $EDINI ",LY:[200,203]PASCAL"
	.SETS $CLEAN "*.PTC;*/DE/NM"
.COM68K:.SETS $MICRO "68"
	.SETS $LBTYP "68K"
	.SETS $RUN "; "
	.SETS $HEXSW "-S -M"
.;	.SETS $NUMLB "LY:[200,201]CNL.68K"
.;	.SETS $PLOLB "LY:[200,201]CPLOT.68K"
.COMUP:	.SETS $LIBR "LBY"
	.SETS $TKB "LKR"
	.SETS $TKTYP "LDA"
	.SETS $OTSLB "LB:[1,1]LBPCPM.'$LBTYP'"
	.SETS $OBTYP "O"
	.SETS $CONMK " -"
	.IF $CLEAN <> "" .SETS $CLEAN $CLEAN+","
	.SETS $CLEAN $CLEAN+"*.CP1;*/DE/NM,*.CP2;*,*.A"+$MICRO+";*,CTEMPC.1;*"
	.GOTO HELP
.TRYLD1: .IF P0 <> "CORALL" .GOTO TRYCKL
	.SETS $EDINI ",LY:[200,203]CORAL"
	.GOTO COMCLD
.TRYCKL: .IF P0 <> "CORALKL" .GOTO TRYBCL
	.SETS $CORSW "/K"
	.SETS $EDINI ",LY:[200,203]CORALK"
.COMCLD: .SETS $COCSW ":Q"
	.GOTO COMLD
.TRYBCL: .IF P0 <> "BCPLL" .GOTO TRYRAT
	.SETS $COCSW ":DT390"
.COMLD:	.SETS $RUN "LD1 @"
	.SETS $OBTYP "BIN"
	.SETS $TKTYP "LNK"
	.SETS $TKB "LD1"
	.SETS $CMPIL "CPLCOR"
	.SETS $COGEN "BOB"
	.SETS $CLEAN "TEMP.OCD;*/DE/NM"
	.GOTO HELP
.TRYRAT: .IF P0 <> "RATFOR" .GOTO TRYRTD
	.SETS $NUMLB "LY:[200,201]FNL/LB"
	.GOTO COMRAT
.TRYRTD: .IF P0 <> "RATFORD" .GOTO ILLCOM
	.SETS $NUMLB "LY:[200,201]FNLD/LB"
.COMRAT: .SETS $CMPIL "CPLRAT"
	.SETS $CLEAN "*.FIV;*/DE/NM"
.CMRTF7: .SETS $PLOLB "LY:[200,201]FPLOT/LB"
	.SETS $VTLIB "LY:[200,201]VTLIB/LB,STRLIB/LB
	.SETS $STRLB "LY:[200,201]STRLIB/LB
	.SETS $OTSLB "LB:[1,1]F77OTS/LB"
	.SETS $EDINI ",LY:[200,203]FORTRAN"
	.SETS $LANG "F77"
	.ENABLE LOWERCASE
	.GOSUB QUESTN .ASK [:20S] YN Using FORTRAN-77-DEBUG
	.IFF YN .GOTO HELP
	.SETS $LANG "F7D"
	.SETS $FDB "/-OP/DB"
	.SETS $DEBUG "LB:[1,1]F77DBG/DA"
	.SETS $TKB "TKB"
.; Print help text if required.
.HELP:	.IF P1 <> "HELP" .IF P1 <> "?" .GOTO SETED
	; Run as @'P0' [<file list>] [<command>]
	;	<command> blank		causes task to be built on completion
	;	<command> /		exit without no task build
	;	<command> +		reprompts for a new list of files when done
	;	<command> <		compresses library (if any)
	;	<file list> blank	prompts for list/<command>
	; File switches:
	;	none			'$CMPAS' only
	;	/LI			'$CMPAS' and list on any printer
	;	/LO			list only, on any printer, (don''t '$CMPAS')
	;	/PR			'$CMPAS' and list on LP:
	;	/PO			list on LP: only (don''t '$CMPAS')
	;	/NC			don''t '$CMPAS' or list.
	;
	.ASK YN Press return for further notes
	;
	; The first file named is assumed to be the main segment, and names the
	; task. Unless it already exists, a build command file with name
	; "main"BLD.CMD is created.
	;
	.IF P0 <> "MACRO" .GOTO HLPNMC
	; If a file "main"ASM.CMD exists, it will be read to find any prefix files
	; which should be used in assembly. The format of each line of this file
	; should be:
	;
	; <module>=<prefix1>,<prefix2>,...<prefixN>,<module>
	;
	; Do not include a list file; one will be added if required.
	;
.HLPNMC: ; If a library file "main".OLB exists, object modules are included in it,
	; and the task is built from this. If not, it is built with all the object
	; modules named in "main"BLD.CMD . If a library is used, the object modules
	; themselves are deleted after insertion into it.
	;
	; Normally, the successfully built task is RUN (unless it is a microprocessor
	; program), but if a file "main"RUN.CMD exists, this is used instead.
	;
	.IF P0 = "MACRO" .ASK YN Press return for more
	;
	; Answer any question with <escape> to pass commands straight to '$CLI'.
	; Answer '$CLI'> prompt, which then appears, with CR to return to previous
	; question, = to repeat last command you gave '$CLI'>, - to edit it.
	;
	; Answer / to any question to exit via a cleanup sequence, // to skip the
	; cleanup. Using ctrl/Z may leave rubbish in your directory, and the CLI
	; set to MCR.
	;
	.SETS P1 ""
.; Try to set user's editor. If there is an EDTINI.EDT file in the current
.; directory, assume he uses EDT. If not, leave $EDITR null, and he will be
.; asked the first time he wants to edit
.SETED:	.SETS $EDITR ""
	.TESTFILE EDTINI.EDT
	.IF <FILERR> = 1 .SETS $EDITR "EDT"
	.RETURN
.;
.ILLCOM: ; ERROR: ILLEGAL OR UNSUPPORTED LANGUAGE: 'P0'
	.EXIT 2
