rem *_________________ section 5.0 ________________*
rem *            STOCK PRICE UPDATE ROUTINE        *
rem *            --------------------------	   *
rem *	UPDATED: January 10, 1983		   *
rem *	BY:	 Edward A. Valenzuela		   *
rem *	VERSION: TRUNCATED FOR STOCK BASE PROGRAM  *
rem *		 --------------------------------  *
rem *	REVISION: 1.30				   *
rem *----------------------------------------------*

rem ----- requires subroutines -----
rem          scrnin.bas   ... for screen handling      

5200 rem ... update the current price of each stock ...

print clear$
     print "enter date of current stock prices: mo/dy/yr"
     input newdate$
        nbegin%=1
	sum1 =0
	sum2 =0
	sum3 =0
print clear$
 GOSUB 5250

5210 for i%=nbegin% to nstk%
  print fn.line$(14)           
    for j%=1 to 4              
      print fn.clear$(2,line%) 
    next j%                    
  print fn.line$(16); \  
        "INSTRUCTIONS: ENTER stock price for "; namstk$(i%); BELL$
     input NEWprice(i%)
 GOSUB 5250 : rem ...print heading
 GOSUB 5255 : rem ...print record

     next i%

 FOR I%=1 to nstk%          
     oldval = nshrs%(i%)*OLDprice(i%)
	sum2 = sum2 + oldval
     newval = nshrs%(i%)*NEWprice(i%)
	sum3 = sum3 + newval
     NEWvalue(i%) = newval
     incvalue(i%) = newval - oldval
        sum1 = sum1 + incvalue(i%)
 rem ... check for no oldvalue ...
 if oldval = 0 then pcntinc(i%) = 0 else \
    pcntinc(i%) = ( incvalue(i%)/oldval * 100. )
 NEXT I%

 if sum2 = 0 then sum9 = 0 else sum9 = sum1/sum2 * 100.
  
if end #8 then 5213
  read #8; OLDprice(i%),dummyprice
5213 namstk$(i%)="S&P 500"
  print fn.line$(15); fn.clear$(2,line%) : \
      print fn.clear$(2,line%) : \
  print fn.line$(16); \  
        "INSTRUCTIONS: ENTER stock price for "; namstk$(i%); BELL$
     input NEWprice(i%)
  incvalue(i%) = NEWprice(i%) - OLDprice(i%)
 if OLDprice(i%) = 0 then pcntinc(i%) = 0 else \
    pcntinc(i%)=( incvalue(i%)/OLDprice(i%) * 100. )

rem ... ASK IF ANY MISTAKES ...
PRINT
print "You now have a chance to correct input errors"

5308 input "any price changes ? (y/n)?"; yes$
if yes$ = "n" or yes$ = "N" then goto 5310 
input "enter number of stock for price change"; num%
     previous.value = nshrs%(num%)*newprice(num%)
print "price for "; namstk$(num%); " is "; newprice(num%)
input "enter correct price "; newprice(num%)

     oldval = nshrs%(num%)*oldprice(num%)
     newval = nshrs%(num%)*NEWprice(num%)
	sum3 = sum3 + newval - previous.value
     NEWvalue(num%) = newval
     incvalue(num%) = newval - oldval
        sum1 = sum1 + incvalue(num%) - (previous.value-oldval)
rem ... check for no oldvalue ...
 if oldval = 0 then pcntinc(num%) = 0 else \
    pcntinc(num%) = ( incvalue(num%)/oldval * 100. )

 if sum2 = 0 then sum9 = 0 else sum9 = sum1/sum2 * 100.

GOTO 5308

5310 rem ----- sort the percentage increases -----

5250 rem ... home cursor, print header ...
 print home$
   for j%=1 to 4
   print fn.clear$(2,line%)
   next j%
 print home$
 print tab(4); " ***** STOCK PRICE UPDATE *****"
 print
 print "number  STOCK NAME  OLD PRICE  NEW PRICE  change" 
 print "----------------------------------------  ------"
 print
RETURN
                  
5255 rem ... display next record ...
  if i% < 6 then print fn.line$( 4 + fn.mod%(i%,5) ) else \
     print fn.line$(24) : print fn.line$(9)
  pq = newprice(i%) - oldprice(i%)
  print using \
   " ###  / stock  name /  ##.###   ##.###    ###.###" ; \
   i%,namstk$(i%),oldprice(i%),newprice(i%),pq
RETURN

5410 rem ----- SUBROUTINE WRITE TO FILE -----
 print # 1 ; nstk%,newdate$,olddate$
 for i%=1 to nstk%
   print #1; NEWprice(i%),OLDprice(i%)
 next i%
   print #1; NEWprice(i%),OLDprice(i%) : rem S&P 500

rem ...... close all open files ......
  CLOSE 1

5480 RETURN

5999 RETURN

rem *------------ end of weekly update ------------*