rem *------------- Section 1.9 --------------------*
rem *						   *
rem *    CREATE TRANSACTION FILE FOR FIRST TIME    *
rem *	 --------------------------------------    *
rem *	WRITTEN: February 25, 1983		   *
rem *	BY:	 Edward A. Valenzuela		   *
rem *	VERSION: 1.35				   *
rem *----------------------------------------------*
				
rem ----- requires following subroutines -----
rem 
rem ...	scrnin.bas
rem ... stkcreat.bas

3700 rem 

print clear$; \
 	fn.down$(2); \
	fn.right$(10); "STOCK TRANSACTION FILE"

print down$
print fn.right$(4); "0 = return to main menu"
print fn.right$(4); "1 = ADD to transaction file"
print fn.right$(4); "2 = ORIGINAL CREATION OF FILE"

print down$; fn.right$(4); "INSTRUCTIONS: enter menu selection"
print fn.right$(4); bell$;
  input "              and hit return"; field%

if field% = 0 then goto 900
on field% gosub 3811,3711 

RETURN

3711 rem ...... original creation ......
 ntrans% = 1
 moretrans$ = "y"

 create "B:TRANSACT.DAT" recl 80 as 1 
gosub 3705

RETURN

REM * ----------- SUBROUTINES ---------- *

3811 rem ..... add to transaction file ......
 ntrans% = 1
 moretrans$ = "y"

 OPEN "B:TRANSACT.DAT" RECL 80 AS 1
rem ... read to EOF ...
  if end #1 then 3813

 while moretrans$ = "y"
   read #1; nshrs%,namstk$,price,xchng$,purdate$,commission, \
            totpurprice,symbol$
   ntrans%=ntrans% + 1
 wend
   nstk% = 1
3813 gosub 3705
RETURN

3705 while moretrans$ = "y"
  gosub 3710    
  gosub 3715    
  gosub 3755    
  RETURN

rem ...... create screen display ...................

3710 print clear$; \
           fn.down$(1); \
           fn.right$(15); "STOCK PURCHASE DATA"
     print down$; fn.right$(5);     "STOCK NAME:"
     print fn.right$(3);          "BOUGHT/SOLD?:"
     print fn.right$(2);         "NUMBER SHARES:"
     print fn.right$(5);            "TRADE DATE:"
     print fn.right$(5);            "TOTAL COST:"
     print fn.right$(5);            "COMMISSION:"
     print fn.right$(9);                "SYMBOL:"
     print fn.right$(1);        "BUY/SELL PRICE:"

     print down$; fn.right$(2); "INSTRUCTIONS:"
rem ...... enter data

RETURN

3715 gosub 8800    rem .. name stock
     gosub 8811    rem .. bought/sold
     gosub 8820    rem .. number shares
     gosub 8830    rem .. purchase date 
     gosub 8840    rem .. total cost
     gosub 8850    rem .. commission
     gosub 8860    rem .. symbol
     gosub 8813    rem .. purchase price

rem ...........field corrections....................
rem ... instructions on line 13, column 16

3720 print fn.line$(13); fn.clear$(16,line%); fn.right$(16); \
          "SELECT FIELD TO BE CORRECTED"
    print fn.right$(2); "0 = no changes"
    print fn.right$(2); "1 = stock name           ";"5 = total purchase cost"
    print fn.right$(2); "2 = bought/sold          ";"6 = commission charges"
    print fn.right$(2); "3 = number of shares     ";"7 = stock symbol"
    print fn.right$(2); "4 = date purchased/sold  ";"8 = price per share"
    print    
3730 print fn.right$(6);bell$;
    input "WHICH FIELD DO YOU WANT TO CHANGE?"; field%

rem ... wait for valid field selection ...

while (field% < 0) or (field% > 8)
  print up$; fn.clear$(6,line%); fn.right$(16);
  input "ENTER A FIELD BETWEEN 0 AND 8: "; field%
wend

rem ... make valid correction ...

if field% eq 0 then goto 3740
if field% ne 0 then             \
  print fn.line$(13);           \
    fn.clear$(16,line%)    :\
  for j% = 1 to 9              :\
    print fn.clear$(2,line%)  :\
  next j%                      :\
    print fn.clear$(2,line%)   :\
  on field% gosub 8800,          \ re-enter name
                  8811,          \ re-enter bought/sold
                  8820,          \ re-enter shares
                  8830,          \ re-enter date
                  8840,          \ re-enter purchase cost
                  8850,          \ re-enter commission
                  8860,          \ RE-ENTER SYMBOL
                  8813:          \ re-enter purchase price
goto 3720                       

3740 rem ... 0 was entered, no changes selected ...

rem ... ask for reverification ...

print fn.right$(16);bell$;
 input "are you sure?"; y$

rem ... wait for yes or no

while (y$ ne "y") and  (y$ ne "n")
     print up$; fn.clear$(16,line%); fn.right$(16);bell$;
     input "enter y for yes or n for no"; y$
wend

  if y$ = "y" then goto 3750
  if y$ = "n" then \
  print up$; fn.clear$(2,line%): \
  print fn.clear$(2,line%)

goto 3730

3750 RETURN

rem ...........valid data entry, store the record.......................
3755 rem
k% = nstk%
  print #1; nshrs%(k%),namstk$(k%),NEWprice(k%),xchng$(k%),purdate$(k%), \
        COMMISSION(K%),totpurprice(k%),symbol$(k%)

  print fn.line$(13); \
    fn.clear$(16,line%) 
  for j% = 1 to 8     :
    print fn.clear$(2,line%)  :
  next j%             :
moretrans$ = fn.entry$(0,44, \
 "input another purchase/sell? y or n?",13,16)
 
wend
rem ***** end of while moretrans$ = "yes" *****

close 1

3799 RETURN

rem ***********************************************
rem *              SUBROUTINES                    *
rem ***********************************************

8811 xchng$ = fn.entry$(8,17,\
      "enter B for BUY, S for SELL, SPL for SPLIT",13,16)
    xchng$(nstk%) = ucase$(xchng$)
    if xchng$(nstk%) = "B" then sale$="bought" 
    if xchng$(nstk%) = "S" then sale$="sold" 
    return

8813 price$ = fn.entry$(2,17, \
      "enter price per share " + sale$,13,16)
    NEWprice(nstk%) = val(price$)
    return


8800 temp$ = fn.entry$(9,17,\
      "enter name of stock",13,16)
rem ...... check name length ...... restrict to 24 characters
    namstk$(nstk%) = left$(temp$,24)
    return

8820 nshrs$ = fn.entry$(7,17,\
      "enter number of shares " + sale$,13,16)
    nshrs%(nstk%) = val(nshrs$)
    return

8830 purdate$(nstk%) = fn.entry$(6,17,\
      "enter date: month/day/year " + sale$,13,16)
    return

8840 totpurprice$ = fn.entry$(5,17,\
      "enter total value of trade",13,16)
    totpurprice(nstk%) = val(totpurprice$)
    return

8850 commission$ = fn.entry$(4,17,\
      "enter total commission charges",13,16)
    commission(nstk%) = val(commission$)
    return

8860 SYMBOL$ = FN.ENTRY$(3,17,\
      "ENTER STOCK SYMBOL",13,16)
    SYMBOL$(NSTK%) = UCASE$(SYMBOL$)
    RETURN

rem *-------- end subroutine stktrans -------------*