C NAME: INSTALL
C AUTHOR: O.K.OLMSTEAD
C DATE: 6/78
C FUNCTION: CONTROLLER TO BUILD A MULTIUSER VERSION OF AD2000
C INPUT:
C	NUMBER OF CLX TO CHANGE FROM USER (OVERLAY # -1)
C	MUAD2K.TSK AT [50,4] (THE TARGET IMAGE)
C	A CLXNNN.TSK FILE CONTAINING THE REAL OVERLAY (SOURCE FILE)
C OUTPUT:
C DESCRIPTION:
C	THIS IS A SIMPLE MINDED CONTROLLER TO INSTALL OVERLAYS ONE AT A
C	TIME AS SPECIFIED BY THE USER.  SINCE ALL OVERLAYS EXCEPT ONE
C	ARE NUMBERED, THEY ARE IDENTIFIED BY THE USER BY THEIR NUMBER.
C	THE FIRST OVERLAY OF MUAD2K IS MUSTRT AND IS IDENTIFIED BY A -1.
C	THE NUMBERS ARE ADJUSTED TO REFLECT THE OVERLAY'S ACTUAL POSITION.
C
	INTEGER STATUS	!STATUS RETURN
	LOGICAL*1 RESP,Y
	LOGICAL*1 NAM(6)
	DATA Y/'Y'/
	DATA NAM/'C','L','X',0,0,0/
C
C
	CALL IRAD50(6,'MUAD2K',TARGET)	!TARGET FILE NAME
1	WRITE(5,1000)
1000	FORMAT(' INPUT CLX # ',$)
	READ(5,1001)N		!OVERLAY # +1
1001	FORMAT(I)
C	
	IF (N .GE. 0) GOTO 4
C	SPECIAL CASE FOR FIRST OVERLAY (MUSTRT) WHICH IS UNNUMBERED
	CALL IRAD50(6,'MUSTRT',R)
	GOTO 6
4	CONTINUE
C	SOURCE FILE NAMES ARE OF THE FORM CLXNNN.
C	CREATE SOURCE FILE NAME FROM USER SPECIFIED NUMBER
	I1= N/100
	NAM(4) = I1 + "60
	I1 = I1*100
	I2 = (N - I1)/10
	NAM(5) = I2 + "60
	NAM(6) = (N - I1 - I2*10) + "60
	CALL IRAD50 (6,NAM,SOURCE)
C
C	NOW COPY SOURCE OVERLAY INTO TARGET TASK IMAGE
6	CALL INSOVL(N+1,SOURCE,TARGET,STATUS)
	GOTO(10,20,30,40,50,60,70,80,90,100,110,120,130,140)STATUS
	STOP 'BAD STATUS'
10	WRITE(5,1004)N
1004	FORMAT(' FINISHED CLX',I,/,' CONTINUE? [Y/N] ',$)
	READ(5,1002)RESP
1002	FORMAT(A1)
	IF(RESP .EQ. Y) GOTO 1
	STOP 'FINISHED'
20	STOP 'CLX OPEN FAILURE'
30	STOP 'MUAD2K OPEN FAILURE'
40	STOP 'NOT A ROOT BLOCK'
50	STOP 'READ$ ERROR'
60	STOP 'CLX OVERLAY TOO BIG'
70	STOP 
80	STOP 'ROOT LENGTHS DONOT MATCH'
90	STOP 'COPY READ ERR'
100	STOP 'COPY WRITE ERR'
110	STOP 'LOST CLX ALV'
120	STOP 'LOST MUAD2K ALV'
130	STOP 'ERR DURING ALV WRITE'
140	STOP 'NO CLX ROOT SEG DES'
	END
