	PROGRAM SERIES

	BYTE COM$(8),DSP$(8),WRK$(8)
	BYTE COM(80),DSP(80),WRK(80)
	BYTE TAG$(8)
	BYTE TAG(80)
	BYTE NAM$(8)
	BYTE NAM(10,3,1)
	BYTE CON$(80)

	REAL ANUM(17,3)
	REAL BNUM

C		INITIALIZE EACH OF THE STRING ARRAYS

	CALL DEFD$(CON$)
	CALL DEFS$(COM$,COM,80)
	CALL DEFS$(DSP$,DSP,80)
	CALL DEFS$(WRK$,WRK,80)
	CALL DEFS$(TAG$,TAG,80)
	CALL DEFT$(NAM$,NAM,10,3,1)

	DO 20 I=1,3
	DO 10 J=1,17
	ANUM(J,I)=0
10	CONTINUE
20	CONTINUE

	CALL MAKE$(NAM$,1,1,'NO NAME@')
	CALL MAKE$(NAM$,2,1,'NO NAME@')
	CALL MAKE$(NAM$,3,1,'NO NAME@')

C		PRINT IDENTITY OF PROGRAM FOR RECOGNITION

	WRITE(5,70)
	WRITE(5,30)
30	FORMAT(1X,12X,'The SERIES Bit (tm)  - Version 1.01')
	WRITE(5,40)
40	FORMAT(1X,12X,'Copyright (C) 1980    Key Bits Inc.')
	WRITE(5,50)
50	FORMAT(1X,12X,'January, 1980   -   Miami, FL, USA')
	WRITE(5,70)
	WRITE(5,60)
60	FORMAT(1X,25X,'using')
	WRITE(5,70)
	CALL VER$(DSP$)
	J=LEN$(DSP$)
	WRITE(5,120)(DSP(I),I=1,J)
	WRITE(5,70)
70	FORMAT(1X,1X)
	CALL CMD$(CON$)
	I2=MATCH$(CON$,'#@',1)
	GO TO 490


C		PROMPT THE CONSOLE FOR SOME INPUT

80	CONTINUE
	WRITE(5,90)
90	FORMAT(1X,'COMMAND? ')

C		GET A STRING OF CHARACTERS FROM THE CONSOLE

100	CONTINUE
	READ(5,110)COM
110	FORMAT(80A1)

C		STRIP TRAILING GARBAGE CHARACTERS OFF INPUT

	CALL STRIP$(COM$)

C		MOVE COMMAND MESSAGE TO DISPLAY MESSAGE AREA
C		PLACE A COPY IN THE ARRAY WORK FOR TRANSFERS

	CALL MAKE$(DSP$,COM$)

C 		WRITE STRING OF CHARACTERS TO THE CONSOLE

	J=LEN$(DSP$)
	WRITE(5,120)(DSP(I),I=1,J)
120	FORMAT(1X,80A1)
	WRITE(5,70)

C		SEARCH STRING FOR VALID COMMANDS

	I=MATCH$(COM$,'=@',1)
	IF (I.GT.0) GO TO 140
	I=MATCH$(COM$,'NAMES@',1)
	IF (I.GT.0) GO TO 280
	I=MATCH$(COM$,'REPORT@',1)
	IF (I.GT.0) GO TO 330
	I=MATCH$(COM$,'HELP@',1)
	IF (I.GT.0) GO TO 490
	I=MATCH$(COM$,'END@',1)
	IF (I.GT.0) GO TO 580

C		COMMAND NOT FOUND

	WRITE(5,130)
130	FORMAT(1X,'*** INVALID COMMAND ***')
	GO TO 80

C		ASSIGN EITHER VALUES OR TITLES

140	CONTINUE

C		EDIT LEFT SIDE OF = FOR A,B OR C NAME

	IF (I.GT.2) GO TO 190
	I=1
	J=I
	CALL LEFT$(TAG$,COM$,I)
	I=IDEN$(TAG$,'1@')
	IF (I.EQ.0) GO TO 150
	I=IDEN$(TAG$,'2@')
	IF (I.EQ.0) GO TO 160
	I=IDEN$(TAG$,'3@')
	IF (I.EQ.0) GO TO 170
	GOTO 190

C		SET SERIES NAME

150	CONTINUE
	I=1
	GO TO 180

160	CONTINUE
	I=2
	GO TO 180

170	CONTINUE
	I=3

180	CONTINUE
	K=LEN$(COM$)
	L=K-(J+1)
	IF (L.GT.10) L=10
	CALL RIGHT$(TAG$,COM$,L)
	CALL MAKE$(NAM$,I,1,TAG$)
	GO TO 280

C		LOOK FOR PARAMETERS

190	CONTINUE
	I=MATCH$(COM$,'(@',1)
	IF (I.GT.1) GO TO 200
	GO TO 220

200	CONTINUE
	J=LEN$(COM$)
	IF (I.GT.J) GO TO 220
	I=I-1
	J=I
	CALL LEFT$(TAG$,COM$,I)

C		LOOK UP NAMES FOR MATCH

	DO 210 K=1,3
	I=IDEN$(TAG$,NAM$,K,1)
	IF (I.EQ.0) GO TO 240
210	CONTINUE
220 	CONTINUE
	WRITE(5,230)
230	FORMAT(1X,'UNKNOWN SERIES NAME')
	GO TO 80

C		ISOLATE WHICH ELEMENT

240	CONTINUE
	ID=K
	I=MATCH$(COM$,'(@',1)
	I=I+1
	NUM=NVAL$(CON$,COM$,I)
	DECODE(CON$,250)BNUM
250	FORMAT(10X,F14.5)

C		LOAD VALUES FROM STRING

	I=MATCH$(COM$,'=@',1)
	I=I+1
	LOC=BNUM
	DO 270 K=1,40
	NUM=NVAL$(CON$,COM$,I)
	IF (NUM.EQ.0) GO TO 80
	DECODE(CON$,260)ANUM(LOC,ID)
260	FORMAT(10X,F14.5)
	LOC=LOC+1
	IF (LOC.GT.17) GO TO 80
	I=NUM
270	CONTINUE
	GO TO 80

C		LIST NAMES OF SERIES

280	CONTINUE
	WRITE(5,290)
290	FORMAT(1X,'SERIES NAMES')
	WRITE (5,300)
300	FORMAT(1X,'------------')
	DO 320 I=1,3
	CALL MAKE$(DSP$,NAM$,I,1)
	J=LEN$(DSP$)
	IF (J.LT.1) GO TO 320
	WRITE(5,310)I,(DSP(K),K=1,J)
310	FORMAT(1X,I1,2X,80A1)
320	CONTINUE
	WRITE(5,70)
	GO TO 80

C		REPORT SERIES

330	CONTINUE
	I=LEN$(COM$)
	IF (I.GT.7) GOTO 350
	WRITE(5,340)
340	FORMAT(1X,'SERIES NAME NOT RECOGNIZED')
	WRITE(5,70)
	GO TO 80

350	CONTINUE
	J=I-7
	CALL RIGHT$(TAG$,COM$,J)

C		LOOKUP SERIES NAME

	DO 360 K=1,3
	I=IDEN$(TAG$,NAM$,K,1)
	IF (I.EQ.0) GO TO 370
360	CONTINUE
	GO TO 220

C		PRINT SERIES -K-

370	CONTINUE
	N=LEN$(TAG$)
	WRITE(5,380)(TAG(L),L=1,N)
380	FORMAT(10X,'SERIES - ',80A1)
	ICNT=0
	ATOT=0
	AVG=0
	AMAX=ANUM(1,K)
	AMIN=ANUM(1,K)
	DO 410 I=1,17
	WRITE(5,390) I,ANUM(I,K)
390	FORMAT(1X,I5,5X,F14.5)
	IF (ANUM(I,K).EQ.0)GO TO 400
	ICNT=ICNT+1
	ATOT=ATOT+ANUM(I,K)
	IF (ANUM(I,K).LT.AMIN) AMIN=ANUM(I,K)
	IF (ANUM(I,K).GT.AMAX) AMAX=ANUM(I,K)
400	CONTINUE
410	CONTINUE

C		PRINT SUMMARIES

	WRITE(5,420)ATOT
420	FORMAT(1X,'TOTAL     ',F14.5)
	WRITE(5,430)ICNT
430	FORMAT(1X,'COUNT           ',I2,'.00000')
	IF(ICNT.EQ.0)GO TO 440
	IF(ATOT.EQ.0)GO TO 440
	AVG=ATOT/ICNT
	GO TO 450
440	CONTINUE
	AVG=0
450	CONTINUE
	WRITE(5,460)AVG
460	FORMAT(1X,'AVERAGE   ',F14.5)
	WRITE(5,470)AMIN
470	FORMAT(1X,'MINIMUN   ',F14.5)
	WRITE(5,480)AMAX
480	FORMAT(1X,'MAXIMUM   ',F14.5)
	GO TO 80

C		PRINT MENU

490	CONTINUE
	WRITE(5,70)
	WRITE(5,500)
	WRITE(5,510)
	WRITE(5,520)
	WRITE(5,530)
	WRITE(5,540)
	WRITE(5,550)
	WRITE(5,560)
	WRITE(5,570)
	WRITE(5,70)
500	FORMAT(1X,'SERIES COMMANDS')
510	FORMAT(1X,'---------------')
520	FORMAT(1X,'HELP - Display Menu')
530	FORMAT(1X,'NAMES - Display Names')
540	FORMAT(1X,'N=Aaa - Assign Name')
550	FORMAT(1X,'Aaa(M)=N1,N1...Nn - Assign values')
560	FORMAT(1X,'REPORT - Report values')
570	FORMAT(1X,'END - End Series Demonstration')
	GO TO 80

580	CONTINUE
	WRITE(5,590)
590	FORMAT(1X,'The SERIES Bit (tm)')
	WRITE(5,600)
600	FORMAT(1X,'    Goodbye . . .')
	WRITE(5,70)
	IF(I2.GT.0)GO TO 610
	GO TO 630
610	CONTINUE
	CALL CHAIN$('DEMO.COM@')
	WRITE(5,620)
620	FORMAT(1X,'*** DEMO.COM NOT FOUND - RETURNED TO SYSTEM ***@')
630	CONTINUE
	END
