home *** CD-ROM | disk | FTP | other *** search
- ; Script: PORTFOL.SC
- ; Version: 3.5
- ; Date: 23 March 1990
- ;
- ; This script defines the procedures that display a summary of holdings
- ; in a specific portfolio (as requested by the user). It functions
- ; in a similar manner to HOLDINGS.
-
- PROC PortMenu()
- CLEAR
- PAINTCANVAS ATTRIBUTE 31 0, 0, 24, 79
- STYLE ATTRIBUTE 30
- @ 5, 0
- TEXT
- ╔══════════════════════════════════════════════════════════════════════════════╗
- ║ ░░░░ STOCKS APPLICATION ░░░░░░░░░░░░░░░░░░░░░░░░░ PORTFOLIO MENU ░░░░░░░░░░░ ║
- ╟─────────────────╥────────────────────────────────────────────────────────────╢
- ║ Auto Industry ║ Use Auto Industry portfolio. ║
- ╠═════════════════╬════════════════════════════════════════════════════════════╣
- ║ Blue Chip ║ Use Blue Chip portfolio. ║
- ╠═════════════════╬════════════════════════════════════════════════════════════╣
- ║ High Tech ║ Use High Tech Industry portfolio. ║
- ╠═════════════════╬════════════════════════════════════════════════════════════╣
- ║ MainMenu ║ Exit Porfolio menu and return to Main menu. ║
- ╚═════════════════╩════════════════════════════════════════════════════════════╝
- ENDTEXT
- PAINTCANVAS ATTRIBUTE 78 6, 7, 6, 24
- PAINTCANVAS ATTRIBUTE 46 6, 52, 6, 65
- STYLE
- ENDPROC
-
- PROC CLOSED SpecificPort()
- PRIVATE x
- CURSOR OFF
- AskPortName() ; get a portfolio name from user
- IF (NOT Retval)
- THEN RETURN ; user didn't supply name, so return
- ENDIF
- WHILE (NOT CHARWAITING()) ; For as long as user doesn't press key,
- CLEARALL ; clear the workspace,
- SpecQuery1() ; put the portfolio query on workspace.
- WHILE (TRUE)
- LOCK "Price" WL ; Can we get the table?
- IF (Retval) ; yes, so go on
- THEN QUITLOOP
- ENDIF
- SLEEP 500 ; no, so pause before retrying
- ENDWHILE
- SingleDoFeed() ; if users are not on network, simulate changes
- DO_IT! ; process the query
- UNLOCK "Price" WL ; give up lock on table
- CLEARALL
- VIEW "Answer" ; display the resultant Answer table
- MOVETO [Total Share Price]
- MOVETO [Ticker]
- ECHO NORMAL ; turn on ECHO to see results
- PROMPT "Portfolio for " + PortName + " as of " + Time(),
- "Total portfolio value is $" +
- FORMAT("W12,AL,EC",CSUM("Answer", "Total Share Price")) +
- " Press any key to quit."
- ECHO OFF ; turn off ECHO so user doesn't see next query
- ENDWHILE ; return to top of the loop
-
- ; If we drop out of preceding loop, user must have pressed a key.
-
- x = GETCHAR() ; gobble up the keystroke
- CLEARALL ; erase the workspace
- CLEAR ; erase the canvas
- ENDPROC ; SpecificPort
-
-
- ; SpecQuery1 puts the query that does all the work onto the workspace.
- ; The tilde variable ~portname supplies the portfolio name.
- ; CALC _p * _sh calculates total value for a stock.
-
- PROC SpecQuery1()
-
- QUERY
-
- Price | Ticker | Price | Last |
- | CHECK _tick | CHECK _p | CHECK |
-
- Holding | Portfolio | Symbol | Shares |
- | ~portname | _tick | CHECK _sh, CALC _p * _sh AS Total Share Price |
-
- ENDQUERY
- ENDPROC
-
- ; AskPortName does the job of requesting and accepting from the user the
- ; name of the portfolio to display a summary of.
-
- PROC AskPortName()
- PRIVATE n, Nams, Prompts ; first we must get the names of the portfolios
- MENU {Ask} SELECT "Holding" ; Holding table has names of portfolios
- MOVETO [Portfolio] ; portfolio names are in Portfolio field
- CHECK ; so check that field
- DO_IT! ; and perform a query to get names into table
- n = NRECORDS("Answer") ; user has n portfolios (names now in Answer)
- ARRAY Nams[n+1] ; create an array to put the names into,
- ARRAY Prompts[n+1] ; and another array to store prompts for names
- SCAN ; scan through each record of Answer to fill arrays
- Nams[RECNO()] = [Portfolio]
- Prompts[RECNO()] = "Use " + [Portfolio] + " portfolio"
- ENDSCAN
- Nams[n+1] = "MainMenu"
- Prompts[n+1] = "Exit Portfolio menu and return to Main menu."
- CLEARALL
-
- CANVAS OFF
- PortMenu() ; print portfolio menu box
- CANVAS ON
- SHOWARRAY
- Nams
- Prompts
- TO PortName ; display portfolio names in a Paradox-style menu
- RETURN (PortName <> "Esc" AND PortName <> "MainMenu")
-
- ENDPROC ; AskPortName
-
-