.; ###############  FTP.CMD ########################
.SETT  SUB
.DISABLE LOWERCASE
	.SETS  CMPLER "F4P"
	.SETS  DEFOPT "/-SP/CO:30/NOWR/LI:1/TR:ALL"
	.SETS  MAIN "FTP"
	.SETS  NL "NL"
	.SETS  SA "SA"
	.SETS  PS "PS"
	.SETS  PD "PD"
	.SETS  OPTION ""
.START:
;--> Enter program unit name to compile (optional switches may be suffixed and
;   MAIN may be used instead of 'MAIN'), "TKB" to task build, "?" for more
;   information, or CONTROL-Z to stop.  Compile listing options are:
;	/SA  -  save list file (-.LST) - default.
;	/NL  -  no list file produced.
;	/PS  -  print and save list file.
;	/PD  -  print then delete list file.
.START2:
	.ASKS PROG  ?
	.IF  PROG = "?"  .GOTO INFO
	.IF PROG = "TKB"  .GOTO TKB
	.PARSE  PROG "/" PROG OPTION
	.IF PROG = "MAIN" .SETS  PROG "'MAIN'"
	.PARSE  PROG "." PNAME REST
	.IF  REST <> ""  .GOTO OPTS
	.IF PNAME <> "'MAIN'" .AND .IFT SUB .SETS PROG PNAME+".SUB"
	.IF PNAME <> "'MAIN'" .AND .IFF SUB .SETS PROG PNAME+".FTN"
	.IF PNAME =  "'MAIN'"  .SETS PROG PNAME+".FTN"
.OPTS:
	.TESTFILE  'PROG'
	.IF  <FILERR> <> 1  .GOTO FILERR
	.SETS REST ""
.IF  OPTION = ""  .GOTO LIST  ! NO OPTIONS
	.SETS  REST OPTION
	.SETS  OPTION  ""
.LOOK:
	.PARSE  REST "/" FIRST REST
	.IF  NL = FIRST[1:2]  .GOTO NOLIST
	.IF  SA = FIRST[1:2]  .GOTO LIST
	.IF  PS = FIRST[1:2]  .GOTO PRISAV
	.IF  PD = FIRST[1:2]  .GOTO PRIDEL
	.SETS  OPTION OPTION+"/"+FIRST
	.IF  REST = "" .GOTO LIST
	.GOTO LOOK
.NOLIST:
	.IF  REST <> ""  .SETS OPTION OPTION+"/"+REST
	PIP  'PNAME'.OBJ;*/DE/NM
	'CMPLER' 'PNAME'='PROG''DEFOPT'/LI:0'OPTION'
	.GOTO PURGE
.LIST:
	.IF  REST <> ""  .SETS OPTION OPTION+"/"+REST
	PIP  'PNAME'.LST;*/DE/NM,'PNAME'.OBJ;*/DE/NM
	'CMPLER' 'PNAME','PNAME'='PROG''DEFOPT''OPTION'
	.GOTO PURGE
.PRISAV:
	.IF  REST <> ""  .SETS OPTION OPTION+"/"+REST
	PIP  'PNAME'.LST;*/DE/NM,'PNAME'.OBJ;*/DE/NM
	'CMPLER' 'PNAME','PNAME'='PROG''DEFOPT''OPTION'
	PRI  'PNAME'.LST
	.GOTO PURGE
.PRIDEL:
	.IF  REST <> ""  .SETS OPTION OPTION+"/"+REST
	PIP  'PNAME'.LST;*/DE/NM,'PNAME'.OBJ;*/DE/NM
	'CMPLER' 'PNAME','PNAME'='PROG''DEFOPT''OPTION'
	PRI  'PNAME'.LST/DEL
.PURGE:
	.ASK ANS --> Purge old versions of source file: 'PROG'
	.IFT ANS  PIP  'PROG'/PU/NM
;	--> Enter program unit name, "TKB", or "?" for options
	.GOTO START2
.FILERR:
;	ERROR - program file '<FILSPC>' does not exist.
.INFO:
;	Your default options are:
;	'DEFOPT''OPTION'
;	The subroutine files used by 'MAIN' are:
	.OPENR  'MAIN'.TKB
	.READ  REST
.LOOP:
	.READ  REST
	.PARSE  REST "/" FIRST REST
	.IF REST = "" ;	'FIRST'
	.IF REST = "" .GOTO LOOP
	.CLOSE
	.GOTO START
.TKB:
;	--> Deleting old versions of: 'MAIN'.TSK
	PIP  'MAIN'.TSK;*/DE/NM
	.XQT  TKB  @'MAIN'.TKB
	.ASK ANS --> Run program 'MAIN' after task build ?
;	--> "TKB" is now task building 'MAIN'.TSK
	.IFF  ANS  .STOP
;	--> Waiting for "TKB" to finish....
	.WAIT  TKB
	.SETS TASK MAIN[1:6]
;	--> Now executing program 'MAIN',  task name is: 'TASK'
	.XQT  RUN  'MAIN'/CKP=YES/TASK='TASK'
.; ################ EOF #################################
