home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / PDXOS2-1.ZIP / SAMPLE / HOLDINGS.SC < prev    next >
Encoding:
Text File  |  1988-12-29  |  2.8 KB  |  76 lines

  1. ; SCRIPT:     HOLDINGS.SC
  2. ; Version:    2.0
  3. ; Date:       2 May 1987
  4. ;
  5. ;
  6. ; The Holdings selection uses queries to find out the current aggregate
  7. ; value of your portfolios.  Note how the queries are used to full
  8. ; advantage to reduce the amount of programming necessary to summarize
  9. ; the information. PortAggr is the controlling procedure.
  10.  
  11. PROC PortAggr()
  12.   CLEAR                       ; PAL canvas should be clear when we start
  13.  
  14.   WHILE NOT CHARWAITING()     ; Keep updating until user presses a key
  15.     Portpric()                ; The first query gets current prices for our portfolio
  16.     WHILE (TRUE)
  17.       LOCK "Price" WL         ; Can we get Price table?
  18.       IF (retval) THEN QUITLOOP ENDIF ; yes, so go on
  19.       SLEEP 500               ; pause before trying again
  20.     ENDWHILE
  21.     DO_IT!                    ; perform the query
  22.     UNLOCK "Price" WL
  23.     PortSum()  DO_IT!         ; The second query summarizes the information obtained from the first query
  24.     CLEARALL                  ; Done with queries, get them off the workspace
  25.     VIEW "Answer"             ; But put the summary information (query 2) back on
  26.     ECHO NORMAL               ; Turning ECHO NORMAL lets us see the workspace in PROMPT command
  27.     PROMPT "Portfolio Pricing System - Using Real Time Feed",
  28.            "Latest update time is " + TIME() + "  --  Any key to stop"
  29.     ECHO OFF                  ; Turning ECHO OFF insures that next query won't be seen!
  30.   ENDWHILE
  31.  
  32. ; If we get here, user must have pressed a key (and wants to leave module)
  33.  
  34.   x=GETCHAR()           ; Gobble up the character
  35.   CLEARALL              ; Clear up the workspace
  36. ENDPROC
  37.  
  38. ; PortPric puts a query regarding our current portfolio and the current
  39. ; main board information onto the workspace.
  40.  
  41. PROC PortPric()
  42. QUERY
  43.  
  44.  Price | TICKER | PRICE |  LAST  |
  45.        | _tick  | _p    | Check  |
  46.        |        |       |        |
  47.        |        |       |        |
  48.  
  49.  Holding | PORTFOLIO |   SYMBOL    |       SHARES       |
  50.          | Check     | Check _tick | _sh, calc _p * _sh |
  51.          |           |             |                    |
  52.          |           |             |                    |
  53.  
  54. ENDQUERY
  55. ENDPROC
  56.  
  57. ; PortSum puts a query onto the workspace that takes the information
  58. ; from the PortPric query (now in the ANSWER table) and summarizes it
  59. ; for display. Note the following:
  60. ;    - calc max: last update occurred when the last stock traded
  61. ;    - calc count: number of stocks in the portfolio
  62. ;    - calc sum: value of the portfolio as of last update
  63.  
  64. PROC PortSum()
  65.  
  66. QUERY
  67.  
  68.  Answer | LAST       | PORTFOLIO |   SYMBOL   | PRICE * SHARES |
  69.         | calc max   | Check     | calc count | calc sum       |
  70.         |            |           |            |                |
  71.         |            |           |            |                |
  72.  
  73. ENDQUERY
  74.  
  75. ENDPROC
  76.