1 REM CDC STOCK CHARTING 7/80
2 DIM B$(1),C$(1),V$(6),S$(200),FD(50,4),D(8),R$(35),ZZ$(128),Z$(1),CD$(1),X$(5),SS$(4),V(3),ZZBZ$(1)
3 DIM L4Q1$(14),L4Q2$(7),PFMT$(29)
5 ZZBZ$=CHR$(253):B$=" ":C$=",":CD$="}":V$(1,2)="D:":R$="Type Ð to print, ÒÅÔÕÒÎ to continue":GOSUB 8960:? CD$
6 L4Q1$="Latest 4 quar-":L4Q2$="ters of":PFMT$="ÓÔÏÃË¬Å´¬Å³¬Å²¬Å±¬Ä´¬Ä³¬Ä²¬Ä±":TN=698
10 OPEN #7,4,0,"K:ZZK"
20 FOR I=1 TO 50:FOR J=1 TO 4:FD(I,J)=0:NEXT J:NEXT I
600 GOSUB 694:? CD$:FS1=0:TRAP TN:FCN=4:GOSUB 8921
601 FS1=1:TRAP 693:INPUT #1,SP:NSP=INT(SP/4):POSITION 4,12:? "Current portfolio is being loaded"
602 FOR I=1 TO NSP:NOTE #1,HI,LO:FD(I,1)=HI:FD(I,2)=LO:FD(I,0)=I
603 INPUT #1,SS$:INPUT #1,ZZ$:S$(4*I-3,4*I)=SS$:FD(I,3)=0:FD(I,4)=0:NEXT I:CLOSE #1
610 TRAP 680:GOSUB 8967
611 ? CD$:POSITION 4,5
612 ? "This module of STOCK CHARTING":? "allows the user to define a stock":? "for his portfolio."
613 POSITION 4,17:? "Would you like to see the current":? "portfolio? (Y/N) ";:INPUT ZZ$
614 IF ZZ$="YES" OR ZZ$="Y" THEN GOSUB 670
615 FCN=8:GOSUB 8922:GOSUB 8972:FCN=9:GOSUB 8922:STF=0:FS2=1:GOSUB 691
616 ? CD$:POSITION 4,2:? "Enter a new stock or revise a stock":? "   in the portfolio via the format-"
617 POSITION 6,5:? PFMT$:POSITION 4,7:? "Values may be separated by commas"
618 POSITION 3,8:? "or blanks. This module is terminated":POSITION 3,9:? "by pressing ÒÅÔÕÒÎ only. Input values"
619 POSITION 3,10:? "are":POSITION 6,12:? "  STOCK-  Ticker symbol for":POSITION 16,13
620 ? "traded issue (limited to":POSITION 16,14:? "4 characters)."
621 POSITION 6,16:? "  E4-E1   OPTIONAL- ";L4Q1$:POSITION 16,17:? L4Q2$;" EARNINGS data."
622 POSITION 6,19:? "  D4-D1   OPTIONAL- ";L4Q1$:POSITION 16,20:? L4Q2$;" DIVIDEND data."
623 POSITION 2,23:? R$;:GOSUB 661
624 ? CD$:POSITION 3,3:? "FORMAT-":POSITION 6,5:? PFMT$:POSITION 3,7:? "Examples--"
625 POSITION 3,9:? "CDA":POSITION 3,10:? "WCI,1.42,1.55,1.03,1.17":POSITION 3,11:? "DOW,.76,.97,1.19,1.09,";:POKE 82,3
626 ? ".35,.35,.35,.40":POSITION 3,13:? "ÉÎÐÕÔ îå÷ ïò òåöéóåä óôïãë äáôá®":? "Åîä ÉÎÐÕÔ âù ðòåóóéîç ÒÅÔÕÒÎ ïîìù®"
628 POKE 764,255:? 
629 TRAP 40000:FOR I=0 TO 8:D(I)=0:NEXT I:POKE 752,0:INPUT ZZ$:POKE 752,1:LZ=LEN(ZZ$):IF LZ=0 THEN 695
631 EOL=0:CB=1:GOSUB 687:ZST=II-CB:GOSUB 8950:CB=II+1:IF ZSER=1 THEN 644
632 IF EOL=0 THEN GOSUB 9000:IF ERR=1 THEN 644
635 IF ZSER<>3 THEN GOSUB 8961:? #2;"0,0,0,0,0";:FOR I=1 TO 7:? #2;C$;D(I);:NEXT I:? #2;C$;D(8):STF=STF+1:GOTO 644
636 IF ZSER=3 THEN ? "Portfolio full"
644 CRROW=PEEK(84):IF CRROW>21 THEN POSITION 3,16:? "œ":POSITION 3,CRROW-1:GOTO 644
645 GOTO 629
650 ? CD$:POSITION 3,12:? "Current portfolio is being revised":GOSUB 740:GOSUB 670
651 ? CD$:POSITION 3,11:? "Insert STOCK CHARTING system disk":GOSUB 678
652 TRAP 654:RUN "D:STOCK"
654 TRAP 40000:IF PEEK(195)=170 THEN POKE 195,0:OPEN #7,4,0,"K:":GOTO 651
655 GOTO 681
661 GET #7,ZZKK:IF ZZKK=80 THEN TRAP 669:OPEN #5,8,0,"P:PP":GOTO 666
662 IF ZZKK<>155 THEN 661
663 RETURN 
666 DIS=PEEK(106)*256-961:FOR ZZJJ=1 TO 920:ZZJK=PEEK(DIS+ZZJJ):IF ZZJK>127 THEN ZZJK=ZZJK-128
667 IF ZZJK>95 THEN ZZJK=ZZJK-32
668 ? #5;CHR$(ZZJK+32);:NEXT ZZJJ:CLOSE #5
669 TRAP 40000:? ZZBZ$;:GOTO 661
670 GOSUB 694:? CD$:POSITION 11,1:? "CURRENT PORTFOLIO":POSITION 11,2:? "------- ---------":POKE 82,3:? 
673 SE=0:IF SP=1 THEN POSITION 10,13:? "Portfolio is empty.":GOTO 678
676 FOR I=1 TO SP-4 STEP 4:II=FD(INT(I/4)+1,0):? S$(4*II-3,4*II);"  ";:SE=SE+1:IF SE=6 THEN SE=0:? 
677 NEXT I
678 POSITION 2,23:? R$;:GOSUB 661:RETURN 
680 IF PEEK(195)=170 THEN 611
681 ? "DISK I/O ERROR ",PEEK(195):END 
682 IF Z$>="0" AND Z$<="9" THEN NB=1:RETURN 
683 IF Z$="+" OR Z$="-" AND II=CB THEN NB=1:RETURN 
684 IF Z$="." AND DP=0 THEN DP=1:NB=1:RETURN 
685 II=II+1:GOSUB 9070:II=II-1:ERR=1:RETURN 
686 IF CB>LZ THEN CB=LZ:II=LZ:EOL=1:RETURN 
687 DP=0:NB=DP:FOR II=CB TO LZ:Z$=ZZ$(II,II):IF (Z$=" " AND NB<>0) OR Z$="," THEN RETURN 
688 IF CB<>1 AND Z$<>" " THEN GOSUB 682:IF ERR=1 THEN RETURN 
689 IF Z$<>" " THEN NB=1
690 NEXT II:EOL=1:RETURN 
691 POKE 82,0:POKE 83,39:RETURN 
692 IF PEEK(195)=170 THEN SP=1:CLOSE #1:TRAP 40000:GOTO 800
693 ? "ERROR ";PEEK(195):END 
694 POKE 82,2:POKE 83,37:RETURN 
695 GOSUB 8972:IF STF<>0 THEN 650
696 GOSUB 8967:GOSUB 670:GOTO 651
698 IF PEEK(195)=170 THEN SP=1:CLOSE #1:POSITION 4,11:? "Insert disk containing stock data":GOSUB 678:TN=692:GOTO 600
699 TRAP 40000:GOTO 600
712 INPUT #1;ZZ$:RETURN 
713 INPUT #1,F1,F2,F3,F4,F5:RETURN 
733 ? #3;ZZ$:RETURN 
740 NSP=INT(SP/4):MSP=NSP
741 MSP=INT(MSP/2):KSP=INT(NSP-MSP):J=1:IF MSP=0 THEN 747
742 I=J
743 L=I+MSP:IF S$(4*FD(I,0)-3,4*FD(I,0))<=S$(4*FD(L,0)-3,4*FD(L,0)) THEN 745
744 FT=FD(I,0):FD(I,0)=FD(L,0):FD(L,0)=FT:IF I>MSP THEN I=I-MSP:GOTO 743
745 IF J=KSP THEN 741
746 J=J+1:GOTO 742
747 FCN=4:GOSUB 8922:IF FS1<>0 THEN GOSUB 8921:GOSUB 712
748 FCN=8:GOSUB 8923:? #3;SP:GOSUB 8973:FCN=9:GOSUB 8923
749 FOR I=1 TO NSP:N=FD(I,0):? #3;S$(4*N-3,4*N):IF FD(N,1)=0 THEN GOSUB 8982:INPUT #2,ZZ$:GOSUB 733:GOTO 755
750 GOSUB 8981:GOSUB 712:IF FD(N,3)=0 THEN GOSUB 712:GOSUB 733:GOTO 755
752 GOSUB 713:GOSUB 8982:INPUT #2;F0,F0,F0,F0,F0,F6,F7,F8,F9,F10,F11,F12,F13
753 ? #3;F1;C$;F2;C$;F3;C$;F4;C$;F5;C$;F6;C$;F7;C$;
754 ? #3;F8;C$;F9;C$;F10;C$;F11;C$;F12;C$;F13
755 NEXT I:GOSUB 8973:IF FS1<>0 THEN GOSUB 8971
756 IF FS2<>0 THEN GOSUB 8972
757 GOSUB 8966:GOSUB 8969:RETURN 
770 INPUT #1,SP:NSP=INT(SP/4)
771 FOR I=1 TO NSP:GOSUB 712:S$(4*I-3,4*I)=ZZ$:GOSUB 713:FD(I,1)=F1:FD(I,2)=F2:FD(I,3)=F3:FD(I,4)=F4:FD(I,5)=F5
772 NEXT I:GOSUB 8971:FS1=1:RETURN 
800 TRAP 810:OPEN #1,4,0,"D:STOCK"
802 CLOSE #1:TRAP 40000:? CD$
806 ? CD$:TN=698:GOTO 600
810 TRAP 40000:GOTO 610
8921 OPEN #1,FCN,0,"D:PRTFOLIO":GOTO 8970
8922 OPEN #2,FCN,0,"D:STKDAT":GOTO 8970
8923 OPEN #3,FCN,0,"D:MKTUPD":GOTO 8970
8950 ZSER=0:FOR J=3 TO 6:V$(J,J)=B$:NEXT J:IF ZST>4 THEN ? "Excess ticker symbol":ZSER=1:RETURN 
8951 FOR J=1 TO ZST:IF ZZ$(J,J)<"A" OR ZZ$(J,J)>"Z" THEN ? "Ticker symbol error":ZSER=1:RETURN 
8952 NEXT J:V$(3,ZST+2)=ZZ$(CB,ZST):IF SP=1 THEN J=1:RETURN 
8953 FOR J=1 TO SP-4 STEP 4:IF V$(3,6)=S$(J,J+3) THEN ZSER=2:RETURN 
8954 NEXT J:IF SP<200 THEN RETURN 
8956 ZSER=3:RETURN 
8960 POKE 752,1:RETURN 
8961 NSP=INT(J/4)+1:NOTE #2,HI,LOW:FD(NSP,3)=HI:FD(NSP,4)=LOW:IF ZSER=2 THEN ZSER=0:RETURN 
8963 FD(NSP,0)=NSP:FD(NSP,1)=0:FD(NSP,2)=0:S$(SP,SP+3)=V$(3,6):SP=SP+4:RETURN 
8966 IF FS1<>0 THEN XIO 33,#1,0,0,"D:PRTFOLIO":FS1=0
8967 IF FS2<>0 THEN XIO 33,#2,0,0,"D:STKDAT":FS2=0:RETURN 
8968 RETURN 
8969 XIO 32,#1,0,0,"D:MKTUPD,PRTFOLIO":RETURN 
8970 TRAP 40000:RETURN 
8971 CLOSE #1:GOTO 8970
8972 CLOSE #2:GOTO 8970
8973 CLOSE #3:GOTO 8970
8981 POINT #1,FD(N,1),FD(N,2):RETURN 
8982 POINT #2,FD(N,3),FD(N,4):RETURN 
9000 EOL=0:ERR=0:PARAM=1:FOR VBL=1 TO LZ:GOSUB 9030:D(PARAM)=RESULT:IF PARAM<5 THEN 9010
9005 IF RESULT<0 THEN ERR=1:? "ERROR--Dividend negative (";D(PARAM);")":RETURN 
9010 PARAM=PARAM+1:IF PARAM=9 OR ERR=1 OR EOL=1 THEN RETURN 
9020 NEXT VBL
9030 GOSUB 686:IF ERR=0 THEN GOSUB 9050:CB=II+1:RETURN 
9035 RESULT=0:RETURN 
9050 TRAP 9060:RESULT=VAL(ZZ$(CB,II-1)):TRAP 40000:RETURN 
9060 TRAP 40000:GOSUB 9070:RESULT=0:ERR=1:RETURN 
9070 ? "--ERROR--";:FOR N=CB TO II-1:ZZ$(N,N)=CHR$(ASC(ZZ$(N,N))+128):NEXT N:? ZZ$:RETURN 
