home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / busi / capgains.zip / CAPGAINS.BAS next >
BASIC Source File  |  1989-04-08  |  16KB  |  656 lines

  1. REM ------------------------
  2. REM Capital Gains Calculator
  3. REM by Robert C. Moyers November 23, 1987
  4. REM Modified to conform to Tax Reform of 1986
  5. REM by C. V. Doreza April 1, 1989
  6.  
  7.     CLS
  8.     LOCATE 4, 1
  9.     PRINT SPACE$(23) + "Capital Gain/Loss Calculator"
  10.     PRINT SPACE$(31) + "Version 1.09"
  11.     LOCATE 10, 1
  12.     PRINT SPACE$(19) + "-----------------------------------"
  13.     PRINT SPACE$(19) + "|  Modified to conform to changes |"
  14.     PRINT SPACE$(19) + "|  in the Tax Reform Act of 1986  |"
  15.     PRINT SPACE$(19) + "|         by C. V. Doreza         |"
  16.     PRINT SPACE$(19) + "|                                 |"
  17.     PRINT SPACE$(19) + "| Copyright 1987 Robert C. Moyers |"
  18.     PRINT SPACE$(19) + "-----------------------------------"
  19.     LOCATE 20, 1
  20.     PRINT SPACE$(16) + "Press Enter to acknowledge copyright notice"
  21.  
  22.     now! = TIMER
  23.     DO WHILE (TIMER - now!) < 5
  24.         c$ = INKEY$
  25.         IF LEN(c$) <> 0 THEN
  26.             IF ASC(c$) = 13 THEN
  27.                 EXIT DO
  28.             END IF
  29.         END IF
  30.     LOOP
  31.     CLS
  32.        
  33. REM ---------------------------------
  34. REM 1-6 yymmdd transaction date
  35. REM 8-28 description of transaction
  36. REM 30-39 amount +buy -sell
  37. REM 41-50 price per share always +
  38. REM 52-60 number of shares +buy -sell
  39. REM ---------------------------------
  40.  
  41. REM ---------------------------------
  42. REM define arrays
  43. REM ---------------------------------
  44.     DIM pur.date$(100)
  45.     DIM pur.amount#(100)
  46.     DIM pur.price#(100)
  47.     DIM pur.shares#(100)
  48.  
  49.     DIM liq.date$(100)
  50.     DIM liq.amount#(100)
  51.     DIM liq.price#(100)
  52.     DIM liq.shares#(100)
  53.  
  54.     DIM stg.purdate$(50)
  55.     DIM stg.liqdate$(50)
  56.     DIM stg.shares#(50)
  57.     DIM stg.liqamount#(50)
  58.     DIM stg.puramount#(50)
  59.     DIM stg.gain#(50)
  60.  
  61.     DIM ltg.purdate$(50)
  62.     DIM ltg.liqdate$(50)
  63.     DIM ltg.shares#(50)
  64.     DIM ltg.liqamount#(50)
  65.     DIM ltg.puramount#(50)
  66.     DIM ltg.gain#(50)
  67.  
  68.     pur% = 0
  69.     liq% = 0
  70.     stg% = 0
  71.     ltg% = 0
  72.  
  73. REM -------------------------------------
  74. REM read input file into pur & liq arrays
  75. REM +buy -sell
  76.  
  77.     inp.filespec$ = ""
  78.     WHILE inp.filespec$ = ""
  79.         LOCATE 1, 1
  80.         PRINT SPACE$(28) + "Capital Gains Calculator"
  81.         LOCATE 5, 1
  82.         LINE INPUT "Input file spec (filename.ext) or END: ", inp.filespec$
  83.         CLS
  84.         IF inp.filespec$ = "end" OR inp.filespec$ = "END" THEN SYSTEM
  85.         IF inp.filespec$ <> "" THEN
  86.             GOSUB test.spec
  87.             IF file.error% THEN
  88.                 SOUND 440, 5
  89.                 LOCATE 4, 1
  90.                 PRINT inp.filespec$ + " not found."
  91.                 inp.filespec$ = ""
  92.             END IF
  93.         ELSE
  94.             SOUND 440, 5
  95.             LOCATE 4, 1
  96.             PRINT "Input file specification is required."
  97.         END IF
  98.     WEND
  99.  
  100.     OPEN inp.filespec$ FOR INPUT AS #1
  101.  
  102.     LOCATE 1, 1
  103.     PRINT SPACE$(28) + " Capital Gains Calculator"
  104.  
  105.     old.date$ = "000000"
  106.     WHILE NOT EOF(1)
  107.         LINE INPUT #1, inp.record$
  108.  
  109.         IF LEN(inp.record$) < 60 THEN
  110.             GOTO skiprec
  111.         END IF
  112.  
  113.         inp.date$ = MID$(inp.record$, 1, 6)
  114.         inp.year% = VAL(LEFT$(inp.date$, 2))
  115.         inp.amount# = VAL(MID$(inp.record$, 30, 10))
  116.         inp.price# = VAL(MID$(inp.record$, 41, 10))
  117.         inp.shares# = VAL(MID$(inp.record$, 52, 9))
  118.  
  119.         IF (ABS(inp.amount#) < .005) OR (ABS(inp.price#)) < .005 OR (ABS(inp.shares#) < .0005) THEN
  120.             GOTO skiprec
  121.         END IF
  122.  
  123.         IF inp.date$ < old.date$ THEN
  124.             err.message$ = "File is not in date order"
  125.             GOSUB err.handler
  126.         END IF
  127.  
  128.         old.date$ = inp.date$
  129.         IF ((inp.shares# < 0) AND (inp.amount# > 0)) OR ((inp.shares# > 0) AND (inp.amount# < 0)) THEN
  130.             err.message$ = "Amount and shares must have the same sign"
  131.             GOSUB err.handler
  132.         END IF
  133.  
  134.         IF inp.shares# < -.005 THEN
  135.             liq% = liq% + 1
  136.             IF liq% > 100 THEN
  137.                 CLS
  138.                 PRINT "Too many liquidations, program maximum is 100"
  139.                 SYSTEM
  140.             END IF
  141.  
  142.             liq.date$(liq%) = inp.date$
  143.             liq.amount#(liq%) = 0 - inp.amount#
  144.             liq.price#(liq%) = inp.price#
  145.             liq.shares#(liq%) = 0 - inp.shares#
  146.         ELSE
  147.             IF inp.shares# > .005 THEN
  148.                 pur% = pur% + 1
  149.                 IF pur% > 100 THEN
  150.                     CLS
  151.                     PRINT "Too many purchases, program maximum is 100"
  152.                     SYSTEM
  153.                 END IF
  154.                 pur.date$(pur%) = inp.date$
  155.                 pur.amount#(pur%) = inp.amount#
  156.                 pur.price#(pur%) = inp.price#
  157.                 pur.shares#(pur%) = inp.shares#
  158.             END IF
  159.         END IF
  160. skiprec:
  161.     WEND
  162.  
  163.     liqmax% = liq%
  164.     purmax% = pur%
  165.     purmin% = 1
  166.  
  167. REM ---------------------------------
  168. REM first-in, first-out
  169. REM short term if held for 6 months or less (purchased before 1988)
  170. REM short term if held for 12 months or less (purchased after 1988)
  171.  
  172.     CLS
  173.     LOCATE 1, 1
  174.     PRINT SPACE$(28) + "Capital Gains Calculator"
  175.  
  176.     FOR liq% = 1 TO liqmax%
  177.         liq.yy% = VAL(MID$(liq.date$(liq%), 1, 2))
  178.         liq.mm% = VAL(MID$(liq.date$(liq%), 3, 2))
  179.         liq.dd% = VAL(MID$(liq.date$(liq%), 5, 2))
  180.  
  181.         FOR pur% = purmin% TO purmax%
  182.             pur.yy% = VAL(MID$(pur.date$(pur%), 1, 2))
  183.             puryear% = pur.yy%
  184.             pur.mm% = VAL(MID$(pur.date$(pur%), 3, 2))
  185.             pur.dd% = VAL(MID$(pur.date$(pur%), 5, 2))
  186.  
  187.             IF liq.shares#(liq%) > pur.shares#(pur%) THEN
  188.                 trn.shares# = pur.shares#(pur%)
  189.             ELSE
  190.                 trn.shares# = liq.shares#(liq%)
  191.             END IF
  192.  
  193.             pur.shares#(pur%) = pur.shares#(pur%) - trn.shares#
  194.             liq.shares#(liq%) = liq.shares#(liq%) - trn.shares#
  195.  
  196.             IF pur.shares#(pur%) < .0005 THEN
  197.                 purmin% = pur% + 1
  198.                 trn.puramount# = pur.amount#(pur%)
  199.             ELSE
  200.                 trn.puramount# = pur.price#(pur%) * trn.shares#
  201.                 trn.puramount# = INT(trn.puramount# * 100 + .5) / 100
  202.             END IF
  203.  
  204.             pur.amount#(pur%) = pur.amount#(pur%) - trn.puramount#
  205.  
  206.             IF liq.shares#(liq%) < .0005 THEN
  207.                 trn.liqamount# = liq.amount#(liq%)
  208.             ELSE
  209.                 trn.liqamount# = liq.price#(liq%) * trn.shares#
  210.                 trn.liqamount# = INT(trn.liqamount# * 100 + .5) / 100
  211.             END IF
  212.  
  213.             liq.amount#(liq%) = liq.amount#(liq%) - trn.liqamount#
  214.  
  215.             WHILE pur.yy% < liq.yy%
  216.                 pur.mm% = pur.mm% - 12
  217.                 pur.yy% = pur.yy% + 1
  218.             WEND
  219.  
  220.             dif.x% = (liq.mm% - pur.mm%) * 100 + liq.dd% - pur.dd%
  221.             IF dif.x% >= 1200 OR ((dif.x% >= 600) AND (puryear% < 88)) THEN
  222.                 ltg% = ltg% + 1
  223.                 ltg.purdate$(ltg%) = pur.date$(pur%)
  224.                 ltg.liqdate$(ltg%) = liq.date$(liq%)
  225.                 ltg.shares#(ltg%) = trn.shares#
  226.                 ltg.liqamount#(ltg%) = trn.liqamount#
  227.                 ltg.puramount#(ltg%) = trn.puramount#
  228.                 ltg.gain#(ltg%) = ltg.liqamount#(ltg%) - ltg.puramount#(ltg%)
  229.             ELSE
  230.                 stg% = stg% + 1
  231.                 stg.purdate$(stg%) = pur.date$(pur%)
  232.                 stg.liqdate$(stg%) = liq.date$(liq%)
  233.                 stg.shares#(stg%) = trn.shares#
  234.                 stg.liqamount#(stg%) = trn.liqamount#
  235.                 stg.puramount#(stg%) = trn.puramount#
  236.                 stg.gain#(stg%) = stg.liqamount#(stg%) - stg.puramount#(stg%)
  237.             END IF
  238.  
  239.             IF liq.shares#(liq%) < .0005 THEN
  240.                 GOTO nextliq
  241.             END IF
  242.         NEXT
  243. nextliq:
  244.     NEXT
  245.  
  246. REM -----------------------------------
  247. REM Ask user if 1 year or for all
  248.  
  249.     select.by.year$ = ""
  250.     WHILE select.by.year$ = ""
  251.         LOCATE 5, 1
  252.            
  253.         INPUT "Do you want limit computation of gains to a particular year"; select.by.year$
  254.         select.by.year$ = LEFT$(select.by.year$, 1)
  255.         IF select.by.year$ = "y" THEN select.by.year$ = "Y"
  256.         IF select.by.year$ = "" THEN
  257.             SOUND 440, 5
  258.         END IF
  259.     WEND
  260.  
  261.     tst.year% = 0
  262.     WHILE (tst.year% <= 70) AND (select.by.year$ = "Y")
  263.         LOCATE 6, 1
  264.         INPUT "Please enter year for computation of gains: ", tst.year%
  265.         IF tst.year% > 1900 THEN
  266.             tst.year% = tst.year% - 1900
  267.         END IF
  268.         IF tst.year% <= 70 THEN
  269.             SOUND 440, 5
  270.         END IF
  271.     WEND
  272.  
  273. REM ----------------------------------
  274. REM print gains
  275.  
  276.     stgmin% = 1
  277.     ltgmin% = 1
  278.     stgmax% = stg%
  279.     ltgmax% = ltg%
  280.  
  281.     IF stgmax% > 0 AND select.by.year$ = "Y" THEN
  282.         stgmin% = 0
  283.         FOR stg% = 1 TO stgmax%
  284.             stg.year% = VAL(MID$(stg.liqdate$(stg%), 1, 2))
  285.             IF stg.year% = tst.year% THEN
  286.                 stgmin% = stg%
  287.                 EXIT FOR
  288.             END IF
  289.         NEXT
  290.         IF stgmin% > 0 THEN
  291.  
  292.             FOR stg% = stgmin% + 1 TO stgmax%
  293.                 stg.year% = VAL(MID$(stg.liqdate$(stg%), 1, 2))
  294.                 IF stg.year% > tst.year% THEN
  295.                     stgmax% = stg% - 1
  296.                     EXIT FOR
  297.                 END IF
  298.             NEXT
  299.            
  300.         END IF
  301.     END IF
  302.  
  303.     IF ltgmax% > 0 AND select.by.year$ = "Y" THEN
  304.         ltgmin% = 0
  305.         FOR ltg% = 1 TO ltgmax%
  306.             ltg.year% = VAL(MID$(ltg.liqdate$(ltg%), 1, 2))
  307.             IF ltg.year% = tst.year% THEN
  308.                 ltgmin% = ltg%
  309.                 EXIT FOR
  310.             END IF
  311.         NEXT
  312.         IF ltgmin% > 0 THEN
  313.             FOR ltg% = ltgmin% + 1 TO ltgmax%
  314.                 ltg.year% = VAL(MID$(ltg.liqdate$(ltg%), 1, 2))
  315.                 IF ltg.year% > tst.year% THEN
  316.                     ltgmax% = ltg% - 1
  317.                     EXIT FOR
  318.                 END IF
  319.             NEXT
  320.         END IF
  321.     END IF
  322.  
  323.     out.filespec$ = ""
  324.     WHILE out.filespec$ = ""
  325.         LOCATE 7, 1
  326.         INPUT "Please enter output file spec : ", out.filespec$
  327.         IF out.filespec$ = "" THEN
  328.             SOUND 440, 5
  329.         END IF
  330.     WEND
  331.  
  332.     s$ = out.filespec$
  333.     GOSUB lctouc
  334.     out.filespec$ = s$
  335.  
  336.     IF (MID$(out.filespec$, 1, 3) = "CON") OR (MID$(out.filespec$, 1, 4) = "SCRN") THEN
  337.         dis$ = "Y"
  338.         pagesize% = 20
  339.     ELSEIF MID$(out.filespec$, 1, 3) = "LPT" THEN
  340.         lpt$ = "Y"
  341.         pagesize% = 55
  342.     ELSE
  343.         pagesize% = 32000
  344.     END IF
  345.         
  346.     OPEN out.filespec$ FOR OUTPUT AS #2
  347.     lines% = pagesize%
  348.  
  349.     WHILE security$ = ""
  350.         LOCATE 8, 1
  351.         INPUT "Please enter name of security : ", security$
  352.         IF security$ = "" THEN
  353.             SOUND 440, 5
  354.         END IF
  355.     WEND
  356.  
  357.     tot.shares# = 0
  358.     tot.liqamount# = 0
  359.     tot.puramount# = 0
  360.     tot.gain# = 0
  361.  
  362.     yer.shares# = 0
  363.     yer.liqamount# = 0
  364.     yer.puramount# = 0
  365.     yer.gain# = 0
  366.  
  367.     sal.shares# = 0
  368.     sal.liqamount# = 0
  369.     sal.puramount# = 0
  370.     sal.gain# = 0
  371.  
  372. REM ----------------------------------
  373. REM Print Short Term Gain
  374.        
  375.     IF stgmin% > 0 THEN
  376.         headtext$ = "Short Term Capital Gains for " + security$
  377.         LET dc% = (71 - LEN(headtext$)) / 2
  378.         LET header$ = STRING$(dc%, "-") + headtext$ + STRING$(dc%, "-")
  379.         old.liqdate$ = stg.liqdate$(stgmin%)
  380.         old.liqyear$ = LEFT$(old.liqdate$, 2)
  381.  
  382.         FOR stg% = stgmin% TO stgmax%
  383.             stg.liqyear$ = LEFT$(stg.liqdate$(stg%), 2)
  384.  
  385.             IF old.liqdate$ <> stg.liqdate$(stg%) THEN
  386.                 GOSUB salefoot
  387.                 old.liqdate$ = stg.liqdate$(stg%)
  388.             END IF
  389.  
  390.             IF old.liqyear$ <> stg.liqyear$ THEN
  391.                 GOSUB yearfoot
  392.                 old.liqyear$ = stg.liqyear$
  393.             END IF
  394.  
  395.             GOSUB pagehead
  396.  
  397.             PRINT #2, USING "\    \    \    \ #######.### #########.## #########.## ##########.##"; stg.purdate$(stg%), stg.liqdate$(stg%), stg.shares#(stg%), stg.liqamount#(stg%), stg.puramount#(stg%), stg.gain#(stg%)
  398.  
  399.             sal.shares# = sal.shares# + stg.shares#(stg%)
  400.             sal.liqamount# = sal.liqamount# + stg.liqamount#(stg%)
  401.             sal.puramount# = sal.puramount# + stg.puramount#(stg%)
  402.             sal.gain# = sal.gain# + stg.gain#(stg%)
  403.         NEXT
  404.  
  405.         IF stgmax% > 0 THEN
  406.             GOSUB salefoot
  407.             GOSUB yearfoot
  408.             GOSUB totlfoot
  409.         END IF
  410.     END IF
  411.  
  412. REM ----------------------------------
  413. REM Print Long Term Gain
  414.  
  415.     IF ltgmin% > 0 THEN
  416.         lines% = pagesize%
  417.         headtext$ = "Long Term Capital Gains for " + security$
  418.         LET dc% = (71 - LEN(headtext$)) / 2
  419.         LET header$ = STRING$(dc%, "-") + headtext$ + STRING$(dc%, "-")
  420.         old.liqdate$ = ltg.liqdate$(ltgmin%)
  421.         old.liqyear$ = LEFT$(old.liqdate$, 2)
  422.  
  423.         FOR ltg% = ltgmin% TO ltgmax%
  424.             ltg.liqyear$ = LEFT$(ltg.liqdate$(ltg%), 2)
  425.  
  426.             IF old.liqdate$ <> ltg.liqdate$(ltg%) THEN
  427.                 GOSUB salefoot
  428.                 old.liqdate$ = ltg.liqdate$(ltg%)
  429.             END IF
  430.  
  431.             IF old.liqyear$ <> ltg.liqyear$ THEN
  432.                 GOSUB yearfoot
  433.                 old.liqyear$ = ltg.liqyear$
  434.             END IF
  435.  
  436.             GOSUB pagehead
  437.  
  438.             PRINT #2, USING "\    \    \    \ #######.### #########.## #########.## ##########.##"; ltg.purdate$(ltg%), ltg.liqdate$(ltg%), ltg.shares#(ltg%), ltg.liqamount#(ltg%), ltg.puramount#(ltg%), ltg.gain#(ltg%)
  439.  
  440.             sal.shares# = sal.shares# + ltg.shares#(ltg%)
  441.             sal.liqamount# = sal.liqamount# + ltg.liqamount#(ltg%)
  442.             sal.puramount# = sal.puramount# + ltg.puramount#(ltg%)
  443.             sal.gain# = sal.gain# + ltg.gain#(ltg%)
  444.         NEXT
  445.  
  446.         IF ltgmax% > 0 THEN
  447.             GOSUB salefoot
  448.             GOSUB yearfoot
  449.             GOSUB totlfoot
  450.         END IF
  451.     END IF
  452.        
  453.     GOSUB endpage
  454.  
  455.     CLOSE #1
  456.     CLOSE #2
  457.  
  458.     SYSTEM
  459.  
  460. REM ----------------------------------
  461. REM Subroutine to print total when liquidation date changes
  462.  
  463. salefoot:
  464.     tot.shares# = tot.shares# + sal.shares#
  465.     tot.liqamount# = tot.liqamount# + sal.liqamount#
  466.     tot.puramount# = tot.puramount# + sal.puramount#
  467.     tot.gain# = tot.gain# + sal.gain#
  468.  
  469.     yer.shares# = yer.shares# + sal.shares#
  470.     yer.liqamount# = yer.liqamount# + sal.liqamount#
  471.     yer.puramount# = yer.puramount# + sal.puramount#
  472.     yer.gain# = yer.gain# + sal.gain#
  473.  
  474.     sal.shares# = INT(sal.shares# * 1000 + .5) / 1000
  475.     sal.liqamount# = INT(sal.liqamount# * 100 + .5) / 100
  476.     sal.puramount# = INT(sal.puramount# * 100 + .5) / 100
  477.     sal.gain# = INT(sal.gain# * 100 + .5) / 100
  478.  
  479.     GOSUB pagehead
  480.     PRINT #2, "          ------   ---------    ---------    ---------    ----------"
  481.     PRINT #2, USING "          \    \########.### #########.## #########.## ##########.##"; old.liqdate$, sal.shares#, sal.liqamount#, sal.puramount#, sal.gain#
  482.     PRINT #2, " "
  483.  
  484.     sal.shares# = 0
  485.     sal.liqamount# = 0
  486.     sal.puramount# = 0
  487.     sal.gain# = 0
  488.  
  489.     lines% = lines% + 3
  490.        
  491.     RETURN
  492.  
  493. REM -----------------------------------
  494. REM Subroutine to print total when liquidation year changes
  495.  
  496. yearfoot:
  497.     yer.shares# = INT(yer.shares# * 1000 + .5) / 1000
  498.     yer.liqamount# = INT(yer.liqamount# * 100 + .5) / 100
  499.     yer.puramount# = INT(yer.puramount# * 100 + .5) / 100
  500.     yer.gain# = INT(yer.gain# * 100 + .5) / 100
  501.  
  502.     GOSUB pagehead
  503.     PRINT #2, "          ------   ---------    ---------    ---------    ----------"
  504.     PRINT #2, USING "    Total \    \########.### #########.## #########.## ##########.##"; old.liqyear$, yer.shares#, yer.liqamount#, yer.puramount#, yer.gain#
  505.  
  506.     PRINT #2, " "
  507.  
  508.     yer.shares# = 0
  509.     yer.liqamount# = 0
  510.     yer.puramount# = 0
  511.     yer.gain# = 0
  512.  
  513.     lines% = lines% + 3
  514.       
  515.     RETURN
  516.  
  517. REM ----------------------------------
  518. REM Subroutine to print grand total
  519.  
  520. totlfoot:
  521.     tot.shares# = INT(tot.shares# * 1000 + .5) / 1000
  522.     tot.liqamount# = INT(tot.liqamount# * 100 + .5) / 100
  523.     tot.puramount# = INT(tot.puramount# * 100 + .5) / 100
  524.     tot.gain# = INT(tot.gain# * 100 + .5) / 100
  525.  
  526.     GOSUB pagehead
  527.     PRINT #2, "                   =========    =========    =========    =========="
  528.     PRINT #2, USING "    Grand Total ########.### #########.## #########.## ##########.##"; tot.shares#, tot.liqamount#, tot.puramount#, tot.gain#
  529.     PRINT #2, " "
  530.  
  531.     tot.shares# = 0
  532.     tot.liqamount# = 0
  533.     tot.puramount# = 0
  534.     tot.gain# = 0
  535.        
  536.     RETURN
  537.  
  538. REM ----------------------------------
  539. REM Subroutine to print page heading
  540.  
  541. pagehead:
  542.     IF lines% >= pagesize% THEN
  543.         GOSUB endpage
  544.         lines% = 0
  545.         PRINT #2, header$
  546.         PRINT #2, " "
  547.         PRINT #2, " Date      Date      Shares       Sales       Purchase      Capital"
  548.         PRINT #2, "Bought     Sold                   Amount       Amount        Gains"
  549.         PRINT #2, "------    ------    --------    ---------    ---------    ----------"
  550.     END IF
  551.  
  552.     lines% = lines% + 1
  553.     RETURN
  554.  
  555. REM ----------------------------------
  556. REM Subroutine to handle end of page
  557.  
  558. endpage:
  559.     IF herebefore$ = "Y" THEN
  560.         IF dis$ = "Y" THEN
  561.             LOCATE 25, 1
  562.             INPUT "Press ENTER to continue"; NULL$
  563.             CLS
  564.         ELSEIF lpt$ = "Y" THEN
  565.             PRINT #2, CHR$(12)
  566.         END IF
  567.     ELSE
  568.         IF dis$ = "Y" THEN
  569.             CLS
  570.         ELSEIF lpt$ = "Y" THEN
  571.             PRINT "Ready " + out.filespec$ + " and set form to top of page"
  572.             INPUT "Press ENTER when ready"; NULL$
  573.         END IF
  574.     END IF
  575.     herebefore$ = "Y"
  576.     RETURN
  577.  
  578. REM ----------------------------------
  579. REM Subroutine to convert lower to upper case
  580.  
  581. lctouc:
  582.     FOR c% = 1 TO LEN(s$)
  583.         IF (ASC(MID$(s$, c%, 1)) >= 97) AND (ASC(MID$(s$, c%, 1)) <= 122) THEN
  584.             MID$(s$, c%, 1) = CHR$(ASC(MID$(s$, c%, 1)) - 32)
  585.         END IF
  586.     NEXT
  587.     RETURN
  588.  
  589. REM ----------------------------------
  590. REM Subroutine to test for existence of filespec
  591.  
  592. test.spec:
  593.     file.error% = 0
  594.     ON ERROR GOTO open.error
  595.     OPEN inp.filespec$ FOR INPUT AS #4
  596.     GOTO test.close
  597.  
  598. open.error:
  599.     file.error% = 1
  600.     RESUME NEXT
  601.  
  602. test.close:
  603.     ON ERROR GOTO 0
  604.     CLOSE #4
  605.     IF file.error% THEN
  606.         file.found% = 0
  607.     ELSE
  608.         file.found% = 1
  609.     END IF
  610.  
  611.     RETURN
  612.  
  613. REM ----------------------------------
  614. REM Subroutine to handle errors
  615.  
  616. err.handler:
  617.     CLS
  618.     LOCATE 1, 1
  619.     PRINT SPACE$(28) + "Capital Gains Calculator"
  620.     LOCATE 3, 1
  621.     PRINT "Error in the following transactions:"
  622.     PRINT "YYMMDD DDDDDDDDDDDDDDDDDDDDD AAAAAAAAAA PPPPPPPPPP SSSSSSSSS"
  623.     PRINT inp.record$
  624.     PRINT
  625.     PRINT err.message$
  626.     PRINT
  627.  
  628.     INPUT "Ignore(I) or Cancel(C) ? ", action$
  629.     action$ = LEFT$(action$, 1)
  630.     IF (action$ = "C") OR (action$ = "c") THEN
  631.         SYSTEM
  632.     END IF
  633.  
  634.     inp.amount# = 0
  635.     inp.price# = 0
  636.     inp.shares# = 0
  637.  
  638.     RETURN
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.         
  653.  
  654.  
  655.  
  656.