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

  1. ; Script:     PORTFOL.SC
  2. ; Version:    3.5
  3. ; Date:       23 March 1990
  4. ;
  5. ; This script defines the procedures that display a summary of holdings
  6. ; in a specific portfolio (as requested by the user). It functions
  7. ; in a similar manner to HOLDINGS.
  8.  
  9. PROC PortMenu()
  10.   CLEAR
  11.   PAINTCANVAS ATTRIBUTE 31 0, 0, 24, 79
  12.   STYLE ATTRIBUTE 30
  13.   @ 5, 0
  14.   TEXT
  15. ╔══════════════════════════════════════════════════════════════════════════════╗
  16. ║ ░░░░ STOCKS APPLICATION ░░░░░░░░░░░░░░░░░░░░░░░░░ PORTFOLIO MENU ░░░░░░░░░░░ ║
  17. ╟─────────────────╥────────────────────────────────────────────────────────────╢
  18. ║  Auto Industry  ║   Use Auto Industry portfolio.                             ║
  19. ╠═════════════════╬════════════════════════════════════════════════════════════╣
  20. ║  Blue Chip      ║   Use Blue Chip portfolio.                                 ║
  21. ╠═════════════════╬════════════════════════════════════════════════════════════╣
  22. ║  High Tech      ║   Use High Tech Industry portfolio.                        ║
  23. ╠═════════════════╬════════════════════════════════════════════════════════════╣
  24. ║  MainMenu       ║   Exit Porfolio menu and return to Main menu.              ║
  25. ╚═════════════════╩════════════════════════════════════════════════════════════╝
  26.   ENDTEXT
  27.   PAINTCANVAS ATTRIBUTE 78 6, 7, 6, 24
  28.   PAINTCANVAS ATTRIBUTE 46 6, 52, 6, 65
  29.   STYLE
  30. ENDPROC
  31.  
  32. PROC CLOSED SpecificPort()
  33.   PRIVATE x
  34.   CURSOR OFF
  35.   AskPortName()                         ; get a portfolio name from user
  36.   IF (NOT Retval)
  37.     THEN RETURN                         ; user didn't supply name, so return
  38.   ENDIF
  39.   WHILE (NOT CHARWAITING())             ; For as long as user doesn't press key,
  40.     CLEARALL                            ;   clear the workspace,
  41.     SpecQuery1()                        ;   put the portfolio query on workspace.
  42.     WHILE (TRUE)
  43.       LOCK "Price" WL                   ; Can we get the table?
  44.       IF (Retval)                       ; yes, so go on
  45.         THEN QUITLOOP
  46.       ENDIF
  47.       SLEEP 500                         ; no, so pause before retrying
  48.     ENDWHILE
  49.     SingleDoFeed()                     ; if users are not on network, simulate changes
  50.     DO_IT!                             ; process the query
  51.     UNLOCK "Price" WL                  ; give up lock on table
  52.     CLEARALL
  53.     VIEW "Answer"                      ; display the resultant Answer table
  54.     MOVETO [Total Share Price]
  55.     MOVETO [Ticker]
  56.     ECHO NORMAL                        ; turn on ECHO to see results
  57.     PROMPT "Portfolio for " + PortName + " as of " + Time(),
  58.            "Total portfolio value is $" +
  59.            FORMAT("W12,AL,EC",CSUM("Answer", "Total Share Price")) +
  60.            "           Press any key to quit."
  61.     ECHO OFF                           ; turn off ECHO so user doesn't see next query
  62.   ENDWHILE                             ; return to top of the loop
  63.  
  64. ; If we drop out of preceding loop, user must have pressed a key.
  65.  
  66.   x = GETCHAR()                         ; gobble up the keystroke
  67.   CLEARALL                              ; erase the workspace
  68.   CLEAR                                 ; erase the canvas
  69. ENDPROC  ; SpecificPort
  70.  
  71.  
  72. ; SpecQuery1 puts the query that does all the work onto the workspace.
  73. ; The tilde variable ~portname supplies the portfolio name.
  74. ; CALC _p * _sh calculates total value for a stock.
  75.  
  76. PROC SpecQuery1()
  77.  
  78.   QUERY
  79.  
  80.    Price |   Ticker    |  Price   |  Last  |
  81.          | CHECK _tick | CHECK _p | CHECK  |
  82.  
  83.    Holding | Portfolio | Symbol |          Shares                               |
  84.            | ~portname | _tick  | CHECK _sh, CALC _p * _sh AS Total Share Price |
  85.  
  86.   ENDQUERY
  87. ENDPROC
  88.  
  89. ; AskPortName does the job of requesting and accepting from the user the
  90. ; name of the portfolio to display a summary of.
  91.  
  92. PROC AskPortName()
  93.   PRIVATE n, Nams, Prompts           ; first we must get the names of the portfolios
  94.   MENU {Ask} SELECT "Holding"        ; Holding table has names of portfolios
  95.   MOVETO [Portfolio]                 ; portfolio names are in Portfolio field
  96.   CHECK                              ; so check that field
  97.   DO_IT!                             ; and perform a query to get names into table
  98.   n = NRECORDS("Answer")             ; user has n portfolios (names now in Answer)
  99.   ARRAY Nams[n+1]                    ; create an array to put the names into,
  100.   ARRAY Prompts[n+1]                 ;   and another array to store prompts for names
  101.   SCAN                               ; scan through each record of Answer to fill arrays
  102.     Nams[RECNO()]    = [Portfolio]
  103.     Prompts[RECNO()] = "Use " + [Portfolio] + " portfolio"
  104.   ENDSCAN
  105.   Nams[n+1] = "MainMenu"
  106.   Prompts[n+1] = "Exit Portfolio menu and return to Main menu."
  107.   CLEARALL
  108.  
  109.   CANVAS OFF
  110.   PortMenu()                         ; print portfolio menu box
  111.   CANVAS ON
  112.   SHOWARRAY
  113.     Nams
  114.     Prompts
  115.     TO PortName                      ; display portfolio names in a Paradox-style menu
  116.   RETURN (PortName <> "Esc" AND PortName <> "MainMenu")
  117.  
  118. ENDPROC ;  AskPortName
  119.  
  120.