.; BUILD.CMD - emulates basic+2 BUILD command, but builds basic-2 programs
.ENABLE ESCAPE
.ENABLE SUBSTITUTION
; To abort the build: type ^Z to a question
; Will now build .ODL file & .CMD file for TKB
.ASKS SUB0           What is the main program name
.SETS STRING SUB0
.GOSUB CHECK
.IFT BAD .GOTO QUIT
.ASK DUB Is the main program double precision
.IFT DUB .SETS PRECIS "D"
.IFF DUB .SETS PRECIS "S"
.SETN NUM 1.
.100:
.ASKS SUB'NUM'      Subroutine name ([escape] to quit)
.IFT <ESCAPE> .GOTO BUILD
.SETS STRING SUB'NUM'
.GOSUB CHECK
.IFF BAD .INC NUM
.GOTO 100
.BUILD:
;						[Now building .CMD & .ODL file]
PIP 'SUB0'.CMD;*/DE
.OPEN 'SUB0'.CMD
.DATA PIP 'SUB0'.TSK;*/DE
.DATA TKB @'SUB0'TKB.CMD
.CLOSE
PIP 'SUB0'TKB.CMD;*/DE
.OPEN 'SUB0'TKB.CMD
.DATA SY:'SUB0'/CP/FP=SY:'SUB0'/MP
.DATA UNITS = 30
.DATA ASG = TI:13:16:18:19
.DATA ASG = SY:5:6:7:8:9:10:11:12
.DATA EXTTSK = 952
.DATA //
.CLOSE
PIP 'SUB0'.ODL;*/DE
.OPEN 'SUB0'.ODL
.ENABLE DATA
	.ROOT SUB0-LIBR
.DISABLE DATA
.SETN LIN 0.
.200:
.IF LIN > NUM-1 .GOTO 300
.SETN NXT LIN+1
.SETS THIS SUB'LIN'
.SETS REST "-SUB'NXT'"
.IF LIN >= NUM-1. .SETS REST ""
.SETS FCTR THIS+REST
.ENABLE DATA
SUB'LIN':	.FCTR 'FCTR'
.DISABLE DATA
.INC LIN
.GOTO 200
.300:
.ENABLE DATA
LIBR:	.FCTR LI:[1,5]BM2FCS'PRECIS'P/LB-LB:[1,1]BASIC2/LB
	.END
.DISABLE DATA
.CLOSE
.QUIT:
.STOP
.CHECK:
.IF <STRLEN> > 0 .GOTO CHECK1
; Bad reply: you must give SOME reply !
.GOTO CHECKB
.CHECK1:
.IFT <ALPHAN> .GOTO CHECK2
; Bad reply: you must give only letters and digits !
.GOTO CHECKB
.CHECK2:
.IF <STRLEN> <= 6 .GOTO CHECK3
; Bad reply: only 6 letters/digits allowed
.GOTO CHECKB
.CHECK3:
.SETF BAD
.GOTO CHECKX
.CHECKB:
.SETT BAD
.CHECKX:
.RETURN
