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

  1. ; Script:     GRAPHS.SC
  2. ; Version:    3.5
  3. ; Date:       23 March 1990
  4.  
  5. ; This script defines the procedures that display different type of graphs.
  6. ; DoGraph is the controlling procedure.
  7.  
  8. PROC GraphMenu()
  9.   PAINTCANVAS ATTRIBUTE 31 0, 0, 24, 79     ; change the canvas color to white on blue
  10.   STYLE ATTRIBUTE 30
  11.   @ 5, 0
  12. TEXT
  13. ╔══════════════════════════════════════════════════════════════════════════════╗
  14. ║ ░░░░ STOCKS APPLICATION ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ GRAPH MENU ░░░░░░ ║
  15. ╟───────────────────────╥──────────────────────────────────────────────────────╢
  16. ║  StockPrices          ║  Current, low, high prices in High Tech portfolio.   ║
  17. ╠═══════════════════════╬══════════════════════════════════════════════════════╣
  18. ║  PortfolioComposition ║  High Tech stocks' contribution to portfolio value.  ║
  19. ╠═══════════════════════╬══════════════════════════════════════════════════════╣
  20. ║  StockOwned           ║  Number of shares of stock owned, by portfolio.      ║
  21. ╠═══════════════════════╬══════════════════════════════════════════════════════╣
  22. ║  PortfolioValue       ║  Total value of each portfolio.                      ║
  23. ╠═══════════════════════╬══════════════════════════════════════════════════════╣
  24. ║  MainMenu             ║  Exit Graph menu and return to Main menu.            ║
  25. ╚═══════════════════════╩══════════════════════════════════════════════════════╝
  26. ENDTEXT
  27.   PAINTCANVAS ATTRIBUTE 78 6, 7, 6, 24
  28.   PAINTCANVAS ATTRIBUTE 94 6, 61, 6, 70
  29.   STYLE
  30. ENDPROC
  31.  
  32. PROC SaveOldGraph(Mode)
  33.   Private Mode
  34.   IF Mode = "Begin"                                ; begin the graph
  35.     THEN 
  36.       IF NOT ISFILE("ZZZZGR1.G")
  37.         THEN
  38.           MENU {Image} {Graph} {Save} {ZZZZGR1}    ; save the current graph setting
  39.       ENDIF
  40.       StartGraph = True
  41.     ELSE 
  42.       MENU {Image} {Graph} {Load} {ZZZZGR1}        ; end the graph and load 
  43.                                                    ;   old current graph setting
  44.       MENU {Tools} {Delete} {Graph} {ZZZZGR1} {OK} ; delete the old graph
  45.   ENDIF
  46. ENDPROC
  47.  
  48. PROC CLOSED DoGraph()
  49.   PRIVATE Y
  50.   CURSOR OFF
  51.   StartGraph = False
  52.   WHILE (True)
  53.     CANVAS OFF                          ; turn canvas off to prevent flashing
  54.     CLEAR
  55.     RESET
  56.     GraphMenu()                         ; print main Graph menu box
  57.     CANVAS ON                           ; turn Canvas back on with menu
  58.     SHOWMENU
  59.       "StockPrices" :
  60.         "Current, low, and high prices for High Tech portfolio stocks.",
  61.       "PortfolioComposition" :
  62.         "Pie chart showing High Tech stocks contributions to portfolio value.",
  63.       "StocksOwned" :
  64.         "Number of shares of each stock owned, by portfolio.",
  65.       "PortfolioValue" :
  66.         "Total value of all portfolios.",
  67.       "MainMenu" :
  68.         "Exit Graph Menu and return to Main Menu."
  69.       TO GraphChoice
  70.  
  71.     SWITCH
  72.       CASE GraphChoice = "MainMenu" OR GraphChoice = "Esc" :
  73.         IF StartGraph
  74.           THEN SaveOldGraph("End")
  75.         ENDIF
  76.         CANVAS OFF                       ; turn the canvas off to avoid
  77.         RETURN                           ; flickering when return to MainMenu
  78.         CANVAS ON                        ; now, turn the canvas back on
  79.       CASE GraphChoice = "StockPrices" :
  80.         SaveOldGraph("Begin")
  81.         STYLE ATTRIBUTE 31
  82.         @ 19, 1
  83.         ?? FORMAT ("W78,AC", "Query in progress, one moment please...")
  84.         STYLE
  85.         Graph1()
  86.       CASE GraphChoice = "PortfolioComposition" :
  87.         SaveOldGraph("Begin")
  88.         STYLE ATTRIBUTE 31
  89.         @ 19, 1
  90.         ?? FORMAT ("W78,AC", "Query in progress, one moment please...")
  91.         STYLE
  92.         Graph4()
  93.       CASE GraphChoice = "StocksOwned" :
  94.         SaveOldGraph("Begin")
  95.         STYLE ATTRIBUTE 31
  96.         @ 19, 1
  97.         ?? FORMAT ("W78,AC", "Query in progress, one moment please...")
  98.         STYLE
  99.         Graph3()
  100.       CASE GraphChoice = "PortfolioValue" :
  101.         SaveOldGraph("Begin")
  102.         STYLE ATTRIBUTE 31
  103.         @ 19, 1
  104.         ?? Format ("W78,AC", "Query in progress, one moment please...")
  105.         STYLE
  106.         Graph2()
  107.     ENDSWITCH
  108.     WHILE (CHARWAITING())               ; get all extra keystrokes before
  109.       Y = GETCHAR()                     ; returning to selection menu
  110.     ENDWHILE
  111.   ENDWHILE
  112. ENDPROC  ; DoGraph
  113.  
  114. PROC CLOSED Graph1()                    ; graph for Stockprices Menu
  115.   ; Graph #1: Low, high, current (bar, marker, and override) GRAPH1.G
  116.   PRIVATE QOrder
  117.   MENU {Image} {Graph} {Load} {Graph1}  ; load in the Customize graph
  118.   CLEARALL                              ; clear all tables off workspace
  119.   QOrder = QueryOrder()                 ; save old QueryOrder to restore later
  120.   IF QOrder = "TableOrder"
  121.     THEN SETQUERYORDER IMAGEORDER       ; set new QueryOrder to ImageOrder
  122.   ENDIF
  123.   QUERY
  124.  
  125.    Price |   Ticker   | Price  |  Low   |  High  |
  126.          | CHECK _Tic | CHECK  | CHECK  | CHECK  |
  127.  
  128.    Holding | Portfolio | Symbol |
  129.            | High Tech | _Tic   |
  130.  
  131.   ENDQUERY
  132.   WHILE NOT CHARWAITING()
  133.     SingleDoFeed()                      ; Check to see if the user is on network
  134.     DO_IT!                              ;   Yes, do the query and graph
  135.                                         ;   No, simulate the real-time changes
  136.     MOVETO [Price]                      ; move to a numeric field for graph
  137.     GRAPHKEY                            ; make the graph
  138.   ENDWHILE
  139.   G = GETCHAR()                         ; gobble up the keystroke
  140.  
  141.   IF QOrder = "TableOrder"
  142.     THEN SETQUERYORDER TABLEORDER       ; restore the old QueryOrder
  143.   ENDIF
  144.   CLEARALL                              ; clear all tables off workspace
  145. ENDPROC  ; Graph1()
  146.  
  147. PROC CLOSED Graph2()                    ; Graph for PortfolioValue Menu
  148. ; Graph #2: Total value of each portfolio (3-D bar) GRAPH2.G
  149.   MENU {Image} {Graph} {Load} {Graph2}  ; Load Customize graph
  150.   WHILE NOT CHARWAITING()
  151.     CLEARALL                            ; clear all tables from workspace
  152.     PortPric()                          ; do a first query to get share price from Holding.sc
  153.     SingleDoFeed()                      ; check to see if the user is on the network
  154.     DO_IT!                              ;   yes, do the query and graph
  155.                                         ;   no, simulate the real-time changes
  156.     CLEARALL                            ; clear workspace
  157.     PortSum()                           ; do a second query for total in each portfolio
  158.     DO_IT!
  159.     MOVETO [Total Share Price]          ; move to numeric field for grah
  160.     GRAPHKEY                            ; make the graph
  161.   ENDWHILE
  162.   G = GETCHAR()
  163.   CLEARALL
  164. ENDPROC  ; Graph2
  165.  
  166. PROC CLOSED Graph3()                    ; graph for StocksOwned menu
  167.   ; Graph #3: Use crosstab table to graph (stacked bar)  GRAPH3.G
  168.   PRIVATE QOrder
  169.   MENU {Image} {Graph} {Load} {Graph3}  ; Load Customize graph
  170.   CLEARALL                              ; clear tables from workspace
  171.  
  172.   QOrder = QUERYORDER()                 ; save old QueryOrder to restore later
  173.   IF QOrder = "TableOrder"
  174.     THEN SETQUERYORDER IMAGEORDER       ; set new QueryOrder to ImageOrder
  175.   ENDIF
  176.   QUERY
  177.  
  178.    Holding | Symbol | Portfolio | Shares |
  179.            | CHECK  | CHECK     | CHECK  |
  180.  
  181.   ENDQUERY
  182.   DO_IT!
  183.   MOVETO [Symbol]                       ; move to Alpha field for crosstab
  184.   CROSSTABKEY                           ; do a sum CrossTab by default
  185.   GRAPHKEY                              ; make the graph
  186.   G = GETCHAR()                         ; gobble up the keystroke
  187.   IF QOrder = "TableOrder"
  188.     THEN SETQUERYORDER TABLEORDER       ; restore back the old QueryOrder
  189.   ENDIF
  190.   CLEARALL
  191. ENDPROC  ; Graph3
  192.  
  193. PROC CLOSED Graph4()                    ; Graph for PortfolioComposition Menu
  194.   ; Graph #4: Stock Contribution  (Pie chart)   graph4.g
  195.   MENU {Image} {Graph} {Load} {Graph4}  ; Load Customize graph
  196.   CLEARALL                              ; clear tables from workspace
  197.   QUERY
  198.  
  199.    Price |   Ticker   | Price |
  200.          | CHECK _tic | _p    |
  201.  
  202.    Holding | Portfolio | Symbol |              Shares             |
  203.            | High Tech | _tic   | _sh, CALC _sh*_p AS Total Value |
  204.  
  205.   ENDQUERY
  206.   WHILE NOT CHARWAITING()
  207.     SingleDoFeed()                  ; check to see if the user is on the network
  208.     DO_IT!                          ;   yes, do the query and graph
  209.                                     ;   no, simulate the real-time changes
  210.     MOVETO [Total Value]            ; move to numeric field for graph
  211.     GRAPHKEY                        ; make the graph
  212.   ENDWHILE
  213.   G = GETCHAR()                     ; gobble up the keystroke
  214.   CLEARALL                          ; clear all tables off workspace
  215. ENDPROC  ; Graph4
  216.