1 DIM B$(1),C$(1),V$(6),D$(9),S$(200),FD(50,3),D(8),R$(35),ZZ$(128),Z$(1),CD$(1),ZP$(10),X$(5),SS$(4),V(3),A$(25)
2 DIM MN(11),ZZBZ$(1),E$(3):FOR I=0 TO 11:READ J:MN(I)=J:NEXT I:ZZBZ$=CHR$(253)
3 DATA 1,-2,1,0,1,0,1,1,0,1,0,1
4 B$=" ":C$=",":CD$="}":V$(1,2)="D:":ZP$=",0,0,0,0,0":R$="Type Ð to print, ÒÅÔÕÒÎ to continue":? CD$:GOSUB 8960
5 DIM FR(9):FOR I=0 TO 9:READ F1:FR(I)=F1:NEXT I
6 DATA 0,.12,.25,.25,.37,.5,.62,.75,.75,.87
10 OPEN #7,4,0,"K,KK"
400 GOSUB 490:? CD$:TRAP 498:OPEN #1,4,0,"D:PRTFOLIO":POSITION 4,12:? "Current portfolio is being loaded"
401 GOSUB 770:? CD$:POSITION 3,5:? " This module of STOCK CHARTING":? "allows the user to enter the closing"
402 POSITION 2,7:? "quotations for a stock. The stock":? "must have been previously defined":? "in the user's";
403 ? " portfolio.":POSITION 4,17:? "Would you like to see the current portfolio? (Y/N) ";:POKE 764,255:INPUT ZZ$
404 TRAP 40000
405 IF ZZ$="YES" OR ZZ$="Y" THEN GOSUB 470
406 POKE 764,255:? CD$:POSITION 11,8:? "Enter trading date":POSITION 13,10:? "as MM/DD/YR":POSITION 13,13
407 POKE 752,0:INPUT ZZ$:LX=LEN(ZZ$):IF LX=0 THEN POSITION 13,15:? "Date needed":POSITION 13,13:GOTO 407
410 ZSER=0:GOSUB 460:IF ZSER<>0 THEN POSITION 13,15:? "Date error ":POSITION 13,13:GOTO 407
412 POKE 752,1:JDATE=TDATE:POKE 83,39:GOSUB 8960:GOSUB 493
414 POSITION 10,5:? "* INPUT EXPLANATION *":POSITION 3,7:? "DATE - OPTIONAL- to submit closing"
415 POSITION 10,8:? "data for a different trading":POSITION 10,9:? "date.":POSITION 3,11:? "STOCK- Ticker symbol used by stock"
416 POSITION 10,12:? "exchange. Must be identical":POSITION 10,13:? "to stock definition symbol."
417 POSITION 3,15:? "VOL  - Trading volume in hundreds":POSITION 3,17:? "HIGH":POSITION 3,18:? "LOW  - Trading range for stock"
418 POSITION 3,19:? "CLOSE":GOSUB 476:LZ=1:GOSUB 481
420 GOSUB 493:POSITION 13,5:? "** EXAMPLES **":POSITION 3,7:? "NSM,435,29 1/4,28 5/8,28 7/8":POSITION 3,8
421 ? "DOW 375 31.5 30.75 31":POSITION 3,9:? "5/4/79 WCI 21 32 7/8 32 1/8 32 3/8"
422 POKE 82,2:POSITION 2,11:? "ÉÎÐÕÔ ãìïóéîç ñõïôåó® Åîä ÉÎÐÕÔ âù":? "ðòåóóéîç ÒÅÔÕÒÎ ïîìù®":? :IPCT=0
423 POKE 764,255:CB=1:POKE 752,0:INPUT ZZ$:POKE 752,1:LZ=LEN(ZZ$):IF LZ=0 THEN 440
424 TDATE=JDATE:GOSUB 477:IF ZZ$(CB,CB)<"A" THEN LX=II-1:GOSUB 460:CB=II+1:GOSUB 477:IF ZSER=1 THEN ? "Date error":GOTO 435
425 ZST=II-CB:GOSUB 8950:CB=II+1:IF ZSER<>0 THEN 435
426 GOSUB 9040:IF ERR=1 THEN 435
427 IF PARAM<>5 THEN ? "Input data error":GOTO 435
428 LSP=INT(J/4)+1:IF D(2)<D(4) OR D(3)>D(4) THEN ? "Error-HIGH,LOW,CLOSE-inconsistent":GOTO 435
429 IF D(1)=0 OR D(4)=0 THEN ? "Can not accept zero VOL or CLOSE":GOTO 435
430 IF D(1)>99999 OR D(2)>999 OR D(3)>999 OR D(4)>999 THEN ? "Closing data exceeds program limits":GOTO 435
431 FD(LSP,1)=FD(LSP,1)+1:IF FD(LSP,2)<D(2) THEN FD(LSP,2)=D(2)
432 IF FD(LSP,3)>D(3) OR FD(LSP,3)=0 THEN FD(LSP,3)=D(3)
433 NOTE #1,F1,F2:? #2;LSP;C$;F1;C$;F2:? #1;TDATE;C$;:FOR I=1 TO 3:? #1;D(I);C$;:NEXT I:? #1;D(4):IPCT=IPCT+1
434 IF IPCT=50 THEN GOSUB 500:GOTO 420
435 CRROW=PEEK(84):IF CRROW>21 THEN POSITION 2,14:? "œ":POSITION 2,CRROW-1:GOTO 435
436 GOTO 423
440 IF IPCT>0 THEN GOSUB 500
441 GOSUB 747
442 ? CD$:POSITION 3,12:? "Insert STOCK CHARTING system disk":GOSUB 476
443 TRAP 445:RUN "D:STOCK"
445 TRAP 40000:IF PEEK(195)=170 THEN POKE 195,0:OPEN #7,4,0,"K:":GOTO 442
446 GOTO 499
450 GET #7,ZZKK:IF ZZKK=80 THEN TRAP 459:OPEN #5,8,0,"P:PP":GOTO 456
452 IF ZZKK<>155 THEN 450
453 RETURN 
456 DIS=PEEK(106)*256-961:FOR ZZJJ=1 TO 920:ZZJK=PEEK(DIS+ZZJJ):IF ZZJK>127 THEN ZZJK=ZZJK-128
457 IF ZZJK>95 THEN ZZJK=ZZJK-32
458 ? #5;CHR$(ZZJK+32);:NEXT ZZJJ:CLOSE #5
459 TRAP 40000:? ZZBZ$;:GOTO 450
460 ZSER=0:CS=0:CB=1:FOR I=1 TO LX:IF ZZ$(I,I)="/" THEN 463
461 IF ZZ$(I,I)<"0" OR ZZ$(I,I)>"9" THEN ZSER=1:RETURN 
462 NEXT I
463 IF CB>I-1 AND I=1 THEN ZSER=1:RETURN 
464 V(CS)=VAL(ZZ$(CB,I-1)):CB=I+1:IF I<LX THEN CS=CS+1:GOTO 462
465 YR=V(2)+1900:YL=0:YLF=0:IF YR-4*INT(YR/4)=0 THEN YL=1:IF V(0)=2 THEN YLF=1
466 IF CS<>2 OR V(0)<1 OR V(0)>12 OR V(1)<1 OR V(2)<50 OR V(2)>99 THEN ZSER=1:RETURN 
467 IF V(1)>30+YLF+MN(V(0)-1) THEN ZSER=1:RETURN 
468 TDATE=V(1):IF V(0)>1 THEN FOR I=0 TO V(0)-2:TDATE=TDATE+MN(I)+30:NEXT I:IF V(0)>2 THEN TDATE=TDATE+YL
469 YQ=INT((YR-1949)/4):TDATE=TDATE+1461*YQ+365*((YR-1950)-4*YQ):RETURN 
470 GOSUB 490:? CD$:POSITION 11,1:? "CURRENT PORTFOLIO":POSITION 11,2:? "------- ---------":POKE 82,3:? 
471 SE=0:IF SP=1 THEN POSITION 10,13:? "Portfolio is empty.":GOTO 476
472 SE=0:FOR I=1 TO SP-4 STEP 4:? S$(I,I+3);"  ";:SE=SE+1:IF SE=6 THEN SE=0:? 
474 NEXT I
476 POSITION 2,23:? R$;:GOSUB 450:RETURN 
477 FOR II=CB TO LZ:IF ZZ$(II,II)<>" " AND ZZ$(II,II)<>"," THEN NEXT II:? "Insufficient data":POP :GOTO 435
478 RETURN 
480 STOP 
481 IF LZ<>0 THEN ? CD$:POSITION 3,12:? "Files for accepting closing quotes":POSITION 10,13:? "are being prepared.":GOTO 483
482 ? CD$:POSITION 6,12:? "File maintenance in progress":GOTO 484
483 GOSUB 32100:GOSUB 32000:POSITION 9,20:? "Diskette is ";PR;"% full.":IF DS=0 THEN CLOSE #1:GOSUB 32020:GOTO 442
484 TRAP 485:XIO 33,#1,0,0,"D:STKDAT"
485 OPEN #1,8,0,"D:STKDAT":CLOSE #1:OPEN #1,9,0,"D:STKDAT":TRAP 486:XIO 33,#2,0,0,"D:STKTGS"
486 OPEN #2,8,0,"D:STKTGS":CLOSE #2:OPEN #2,9,0,"D:STKTGS":RETURN 
490 POKE 82,2:POKE 83,37:RETURN 
493 ? CD$:POSITION 3,1:? "Input daily stock closing quotes":POSITION 2,3:? "FORMAT-DATE,STOCK,VOL,HIGH,LOW,CLOSE":RETURN 
498 CLOSE #1:? CD$:IF PEEK(195)=170 THEN POSITION 4,11:? "Insert disk containing stock data":GOSUB 476:? CD$:GOTO 400
499 ? "DISK I/O ERROR ";PEEK(195):END 
500 CLOSE #1:CLOSE #2:OPEN #1,4,0,"D:STKDAT":OPEN #2,4,0,"D:STKTGS":NOTE #2,F3,F4
501 ? CD$:POSITION 12,3:? "One moment please":POSITION 5,6:? "The individual stock quotation"
502 POSITION 5,8:? "files are being updated."
503 POSITION 8,21:? "Update is   0% complete"
505 FOR ISP=1 TO NSP:FD(ISP,0)=0:NEXT ISP:FOR ISP=1 TO IPCT:INPUT #2,LSP,F7,F7:FD(LSP,0)=FD(LSP,0)+1:NEXT ISP:POINT #2,F3,F4
510 FOR ISP=1 TO NSP:IF FD(ISP,0)<>0 THEN V$(3,6)=S$(4*ISP-3,4*ISP):GOSUB 533:TRAP 520:OPEN #3,4,0,V$:CLOSE #3:GOTO 530
515 GOTO 550
520 TRAP 520:CLOSE #3:TRAP 40000
525 OPEN #3,8,0,V$:CLOSE #3:POKE 195,0
530 TRAP 534:OPEN #3,9,0,V$
531 FOR U=4 TO 1 STEP -1:IF V$(U+2,U+2)=B$ THEN NEXT U
532 POSITION 5,12:? "    ";:POSITION 9-U,12:? V$(3,U+2);" is currently being updated.":GOTO 537
533 GOSUB 32100:IF DS>=15 THEN 536
534 CLOSE #3:CLOSE #1:CLOSE #2:GOSUB 32020:IF IPCT=50 THEN 441
535 GOSUB 481:GOTO 441
536 RETURN 
537 FOR TGS=1 TO IPCT:INPUT #2,LSP,F1,F2:IF LSP<>ISP THEN 545
540 POINT #1,F1,F2:INPUT #1,ZZ$:? #3;ZZ$
545 NEXT TGS:CLOSE #3
550 POINT #2,F3,F4:PCT=INT(100*ISP/NSP):POSITION 21-LEN(STR$(PCT)),21:? PCT
553 NEXT ISP:CLOSE #1:CLOSE #2:GOSUB 481:IPCT=0:RETURN 
712 INPUT #1;ZZ$:RETURN 
713 INPUT #1,F1,F2,F3,F4,F5:RETURN 
733 ? #3;ZZ$:RETURN 
747 ? CD$:POSITION 3,12:? "Current portfolio is being revised":CLOSE #1:CLOSE #2:FCN=4:GOSUB 8921:GOSUB 712
748 FCN=8:GOSUB 8923:? #3;SP:GOSUB 8973:FCN=9:GOSUB 8923
749 FOR I=1 TO NSP:? #3;S$(4*I-3,4*I)
750 GOSUB 712
752 INPUT #1;F0,F0,F0,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13
753 ? #3;FD(I,1);C$;FD(I,2);C$;FD(I,3);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 8971:GOSUB 8973
757 GOSUB 8966:GOSUB 8969:RETURN 
770 INPUT #1,SP:NSP=INT(SP/4)
771 FOR I=1 TO NSP:INPUT #1,SS$:GOSUB 713:S$(4*I-3,4*I)=SS$:FD(I,1)=F1:FD(I,2)=F2:FD(I,3)=F3
772 NEXT I:GOSUB 8971:FS1=1:RETURN 
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 V$(3,ZST+2)=ZZ$(CB,II-1)
8953 FOR J=1 TO SP-4 STEP 4:IF V$(3,6)<>S$(J,J+3) THEN NEXT J:? "Ticker symbol error":ZSER=1:RETURN 
8954 RETURN 
8960 POKE 752,1:RETURN 
8965 XIO 33,#2,0,0,V$:GOTO 8970
8966 XIO 33,#1,0,0,"D:PRTFOLIO"
8967 XIO 33,#2,0,0,"D:STKDAT":XIO 33,#1,0,0,"D:STKTGS":GOTO 8970
8969 XIO 32,#3,0,0,"D:MKTUPD,PRTFOLIO"
8970 TRAP 40000:RETURN 
8971 CLOSE #1:GOTO 8970
8972 CLOSE #2:GOTO 8970
8973 CLOSE #3:GOTO 8970
8981 POINT #1,FD(I,1),FD(I,2):RETURN 
8982 POINT #2,FD(I,3),FD(I,4):RETURN 
9040 CC=CB-1:VI=1:CS=0:NB=0:CR=0:CD=0:ERR=0:EOF=0:CPR=0:V(0)=NB:PARAM=1:FOR VBL=1 TO LZ:GOSUB 9070
9041 INTRST=INT(RESULT):IF PARAM=1 THEN D(PARAM)=INTRST:GOTO 9045
9042 D(PARAM)=RESULT:FRACT=RESULT-INTRST:IF FRACT<>0 THEN D(PARAM)=INTRST+0.01*(INT(100*FRACT))
9045 PARAM=PARAM+1:IF EOF=1 THEN RETURN 
9046 NEXT VBL
9070 CC=CC+1:IF CC>LZ THEN 9120
9071 GOTO 9080
9072 IF CS=0 THEN RESULT=V(VI-1):GOTO 9075
9073 GOSUB 9460
9075 EOF=1:RETURN 
9080 IF ZZ$(CC,CC)="," THEN GOSUB 9410:CB=CC+1:GOTO 9085
9081 GOTO 9090
9085 IF CS=0 THEN RESULT=V(VI-1):GOTO 9088
9087 GOSUB 9460
9088 CD=0:CR=0:NB=0:VI=1:RETURN 
9090 IF ZZ$(CC,CC)<>" " THEN NB=1:GOTO 9300
9100 IF NB=1 THEN CP=1
9110 GOTO 9070
9120 IF CPR=1 THEN CPR=0:CC=CB-1:CP=0:NB=0:CD=0:RETURN 
9130 GOSUB 9410:GOTO 9072
9300 IF ZZ$(CC,CC)<>"/" THEN 9360
9310 IF CS=0 THEN GOSUB 9410:CS=1:CB=CC+1:CPR=0:GOTO 9070
9315 GOTO 9320
9320 IF CB=CC THEN CC=CC+1
9321 ? "--ERROR--  ";:FOR N=CB TO CC-1:ZZ$(N,N)=CHR$(ASC(ZZ$(N,N))+128):NEXT N:? ZZ$:ERR=1:EOF=1:RETURN 
9360 IF CP<>0 THEN 9375
9370 IF ZZ$(CC,CC)<="9" AND ZZ$(CC,CC)>="0" THEN 9070
9372 IF ZZ$(CC,CC)="." AND CD=0 THEN CD=1:GOTO 9070
9373 CB=CC:GOTO 9320
9375 IF CS=0 AND CPR=1 THEN CC=CB-1:NB=0:CP=0:CPR=0:CD=0:VI=1:RETURN 
9377 IF CS=0 THEN VI=1
9380 GOSUB 9410:CB=CC:CP=0:CC=CC-1
9383 IF CD=1 THEN CD=0:CR=0:RESULT=V(VI-1):VI=1:RETURN 
9385 IF CS=0 THEN RESULT=V(VI-1):CPR=1:GOTO 9070
9390 GOSUB 9460:RETURN 
9410 TRAP 9450:CP=0:V(VI)=VAL(ZZ$(CB,CC-1)):IF SGN(V(VI))=-1 THEN GOTO 9320
9415 IF V(VI)-INT(V(VI))<>0 THEN CR=1
9420 VI=VI+1:RETURN 
9450 IF CC-CB=0 OR NB=0 THEN RESULT=0:RETURN 
9455 GOTO 9320
9460 IF CS=0 THEN RETURN 
9465 VI=VI-1:IF SGN(V(VI))+SGN(V(VI-1))<>2 OR CR=1 THEN 9320
9470 FRACT=V(VI-1)/V(VI)
9471 IF FRACT<1 THEN RESULT=V(VI-2)+0.01*INT(100*FRACT):CS=0:VI=1:RETURN 
9480 GOTO 9320
32000 DS=DS-26:IF DS<=0 THEN DS=0
32005 PR=100-(DS/681*100):IF PR>99 AND PR<100 THEN PR=99:GOTO 32010
32007 IF PR>0 AND PR<1 THEN PR=1:GOTO 32010
32008 PR=INT(PR)
32010 RETURN 
32020 POSITION 12,18:? "ý ÄÉÓËÅÔÔÅ ÆÕÌÌ ":FOR T=0 TO 300:NEXT T:RETURN 
32100 OPEN #4,6,0,"D:*.*"
32102 INPUT #4;A$:IF A$(2,2)=" " THEN 32102
32103 CLOSE #4
32104 E$=A$(1,3):DS=VAL(E$)
32110 RETURN 
