home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a114 / 1.img / SAMPAPP / SAMPAPP.ZIP / HOLDINGS.SC < prev    next >
Encoding:
Text File  |  1990-08-25  |  2.8 KB  |  74 lines

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