	PROGRAM CURVE
C****************************************************************
C* 								*
C*								*
C*	DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY *
C*	EITHER FOR THE CREATION OR FOR THE CLINICAL EFFICACY	*
C*	OF THIS PROGRAM. USERS MUST ASSUME FULL RESPONSIBILITY	*
C*	FOR ANY RESULTS OR DIAGNOSES OBTAINED FROM THE USE	*
C*	OF THIS PROGRAM. QUESTIONS ON THE EXECUTION OF THIS	*
C*	PROGRAM MUST BE REFERRED BACK TO THE ORIGINAL AUTHOR.	*
C*								*
C* AUTHOR:	SALLY FORSTER					*
C*		C/O DEPARTMENT OF NUCLEAR MEDICINE		*
C*		GUY'S HOSPITAL				*
C*		LONDON, ENGLAND					*
C*								*
C*		TEL: 01-407-7600 EXT 2583/4			*
C*								*
C****************************************************************
	IMPLICIT LOGICAL*1 (A)
	IMPLICIT REAL*4    (C)
	IMPLICIT INTEGER*2 (D-Z)
	COMMON//SAVDES(256),CURVE1(512),CURVE2(512),ICS,ICB,ICOM
	COMMON/IN/NA,A(76),LP,ASEMIC,ASPACE
	COMMON/MAC/AMACRO,AFLAG,ICM,ICN,ANAME(16),IREDNM(4)
	COMMON/INPARA/CPAR(10)
	COMMON/SCREEN/AX(512),CYSCAL,CXSCAL,K,ICOL,CMA,CMI
	COMMON/CH/MACFLG,NAME(3),CSR(20),AL(10,20)
	COMMON/WINDOW/FST,LST
	COMMON/FITBND/UP,LW
	COMMON/SET2X/FSTGP,CG(13)
	COMMON/LINEAR/ALIN,AINTER,ATOSEC
	DIMENSION AINS(2)
	DATA AFL/.FALSE./
	DATA AL/200*' '/
	DATA ASEMIC,ASPACE/';',' '/
	CALL GAMOF
	IPLOT=-1
	INORM=-1
	AINTER=AFL
	ALIN=AFL
	AMACRO=AFL
C*****
	ICS=1
	ICB=2
	ICM=3
	ICN=4
	CALL SETERR(10,0)
C*****
	CALL RCHAIN(FLAG,MACFLG,44)
	IF(FLAG.EQ.0)GOTO 10
	IF(MACFLG.GT.0)GOTO 10
	IF(NAMEMC(2,NL).LT.0)GOTO 10
	IF(MACRUN())1035,20,20
C*****
8	FORMAT(1X,'COMMAND:',$)
9	FORMAT(Q,76A1)
10	IF(.NOT.AMACRO)GOTO 15
	AMACRO=AFL
	CLOSE (UNIT=ICM)
15	WRITE(7,8)
	READ(5,9)NA,A
	LP=1
C*****??COMMAND LINE EMPTY
20	IF(NA.GT.LP)GOTO 25
C*****YES
22	IF(.NOT.AMACRO)GOTO 15
C*****GET NEXT LINE FROM MACRO COMMAND FILE
23	READ(ICM,24,ERR=10,END=10)NA,A
	IF(A(1).EQ.'!')GOTO 23
	LP=1
24	FORMAT(I6,76A1)
C*****NEXT COMMAND
25	IF(A(LP).NE.ASPACE)GOTO 30
	LP=LP+1
	GOTO 25
30	OLP=LP
	AINS(2)=A(LP)
	AINS(1)=A(LP+1)
	LP=LP+2
	ICOM=SEARCH(AINS)
C*****
C*****
C*****INVALID COMMAND
	IF(ICOM.LE.0.OR.ICOM.GT.96)GOTO 1030
C*****
C*****CHAIN TO GAMMA-11
C*****RB
	IF(ICOM.EQ.96)CALL RBGAMA(ICM)
C*****NO RETURN
C*****
C***** MACRO COMMANDS AND CHAIN TO FORTRAN
C*****MC,MP,MR,ME,NE
	IF(.NOT.(ICOM.GT.90.AND.ICOM.LE.95))GOTO 40
	CALL MACCH(ICM,IE)
	GOTO 2000
C*****
C*****COMMAND TAKING NO PARAMETERS
C*****LG,EP,HE,HD,LN,IP,NI,DG,NG
40	IF(.NOT.(ICOM.GE.80.AND.ICOM.LE.89))GOTO 50
	CALL NOPAR(IE)
	GOTO 2000
C*****
C*****INTERPRATE STORAGE PARAMETER STRING
50	IF(IGTPAR(IP).LT.0)GOTO 1040
C*****
C*****POSSIBLY EMPTY PARAMETER STRING
C*****PT,PR,NT,NR
	IF(.NOT.(ICOM.GT.19.AND.ICOM.LT.24))GOTO 60
	CALL EMPPAR(IP,IE)
	GOTO 2000
C*****FITTING COMMANDS
C*****FE,FG,FL,FP,FT
60	IF(.NOT.(ICOM.GT.49.AND.ICOM.LT.55))GOTO 70
	CALL FITCUR(IP,IE)
	GOTO 2000
C*****AT LEAST ONE PARAMETER
70	IF(IP.LT.1)GOTO 1040
C*****COMMANDS TAKING MORE THAN ONE PARAMETER
C*****VA,VS,VM,VD,VI
	IF(.NOT.(ICOM.GE.63.AND.ICOM.LE.67))GOTO 75
	CALL VMAN(IP,ICOM-62,IE)
	GOTO 2000
C*****IN,SM,CH,PP,LP,PK,WD,DP
75	IF(.NOT.(ICOM.GE.55.AND.ICOM.LE.62))GOTO 80
	CALL SOMPAR(IP,IE)
	GOTO 2000
C*****COMMANDS TAKING A SINGLE PARAMETER
80	IF(IP.NE.1)GOTO 1040
C*****CONSTANT ARITHMETIC
C*****CA,CS,CM,CD
	IF(ICOM.GT.29.AND.ICOM.LE.33)GOTO 90
	IF(.NOT.(ICOM.GE.7.AND.ICOM.LE.14))GOTO 100
90	CALL ICASMD(IE)
	GOTO 2000
C*****COMMANDS TAKING A SINGLE INTEGER PARAMETER
100	ISV=INTPAR(1)
C*****LC,CO,RI
	IF(.NOT.(ICOM.GE.15.AND.ICOM.LE.17))GOTO 110
	CALL SNGINT(ISV,IE)
	GOTO 2000
C******TC,TO,TN
110	IF(ICOM.GE.27.AND.ICOM.LE.29)GOTO 120
C******RS,WS,SC,DC,PO,NO
	IF(ICOM.GT.6)GOTO 1030
120	CALL IC1TO6(ISV,IE)
C**********************
C*****
2000	IF(ENDCOM(OLP,IE))10,20,22
C*************
1030	WRITE(7,1031)
1031	FORMAT(1X,'?COMMAND')
	GOTO 1110
1035	WRITE(7,1036)NAME
1036	FORMAT(1X,'?MACRO',3A2)
	GOTO 10
1040	WRITE(7,1041)
1041	FORMAT(1X,'?PARAM')
1110	WRITE(7,1111)(A(I),I=OLP,NA)
1111	FORMAT(1X,'?',76A1)
	GOTO 10
	END
