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

  1. ; Script:     TICKER.SC
  2. ; Version:    3.5
  3. ; Date:       23 March 1990
  4. ;
  5. ; TICKER contains the procedures that create a "tickertape" display of
  6. ; the stocks in the PRICE table.
  7.  
  8. PROC AddChar(s)                         ; add the next characters and display ticker
  9.   PRIVATE l, i
  10.   l = LEN(s)                            ; Find out how many character added to string
  11.   FOR i FROM 1 TO l                     ;   so that we loop right number of times.
  12.     ToPrint = SUBSTR(ToPrint, 2, 50) + SUBSTR(s, i, 1)
  13.     @ 12, 15                            ; add char to ticker line 
  14.     ?? ToPrint                          ; print ticker string on line 12
  15.     SLEEP Delay                         ; short pause, otherwise ticker moves too fast
  16.   ENDFOR
  17. ENDPROC
  18.  
  19. PROC TickerTape()
  20.   PRIVATE ToPrint, x, Delay, BetweenRefresh
  21.   ToPrint = SPACES(80)
  22.   Delay = 100
  23.   BetweenRefresh = 5
  24.   VIEW "Price"                          ; get ticker info from PRICE table
  25.   WHILE (True)                          ; loop until user presses character
  26.     SCAN                                ; use SCAN to move through stocks in table
  27.       IF (CHARWAITING())                ; Did user press a key?
  28.         THEN
  29.           x = GETCHAR()                 ; yes, so let's see what they typed
  30.           WHILE (CHARWAITING())
  31.             Y = GETCHAR()
  32.           ENDWHILE
  33.           SWITCH
  34.             CASE x = 45:                ; user typed minus
  35.               Delay = Delay + 50        ;   so slow the ticker
  36.             CASE x = 43:                ; user typed plus
  37.               Delay = MAX(Delay - 50, 0)  ;  so speed up ticker
  38.             OTHERWISE:                  ; user wants to leave
  39.               CLEARALL                  ;   so clear up the workspace and
  40.               RETURN                    ;   go back to Main menu
  41.           ENDSWITCH
  42.       ENDIF                             ; no, so continue SCAN
  43.       IF (MOD(RECNO(),BetweenRefresh) = 1)
  44.         THEN REFRESH                    ; refresh every BetweenRefresh records
  45.       ENDIF
  46.       AddChar([Ticker] + " " + STRVAL([Price]) +  "   ") 
  47.                                         ; add stock name and price to ticker
  48.     ENDSCAN
  49.   ENDWHILE
  50. ENDPROC  ; TickerTape
  51.  
  52. ; DoTicker is the controlling procedure and performs a few housekeeping
  53. ; chores before calling the routine to display stock information.
  54.  
  55. PROC CLOSED DoTicker()
  56.   CLEAR                      ; clear PAL canvas for ticker
  57.   CURSOR OFF                 ; Cursor not needed in this subsystem
  58.   PAINTCANVAS ATTRIBUTE 0 12, 14, 14, 70                    ; for shadow box
  59.   PAINTCANVAS FILL (" ") 12, 13, 13, 67                     ; clear window
  60.   PAINTCANVAS BORDER FILL " " ATTRIBUTE 78 11, 12, 13, 68   ; for frame
  61.   TickerTape()               ; start the tape
  62.   CLEAR                      ; remove ticker from display before returning to Main menu
  63. ENDPROC
  64.  
  65.