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

  1. ; Script:    BOARD.SC
  2. ; Version:   3.5
  3. ; Date:      23 March 1990
  4. ;
  5. ; The procedures in this script handle the display of the "main board,"
  6. ; the table of stocks shown with real-time updates. Since the table may
  7. ; be larger than one display screen in length, it is shown in "pages,"
  8. ; with each page being displayed for a short period of time before moving
  9. ; on to the next page.
  10. ;
  11. ; SeeBoard is the main procedure here, and controls the initial display
  12. ; of the "main board." It uses the ShowNSleep procedure to display
  13. ; additional pages of the board, if any.
  14.  
  15. PROC CLOSED SeeBoard()
  16.   PRIVATE NStocks, NScreens, i
  17.  
  18.   CLEARALL                    ; make sure that the workspace is clear
  19.   VIEW "Price"                ; Main Board consists of the Price table shown in real time
  20.   MOVETO [Chg]
  21.   MOVETO [Ticker]             ; position cursor so that Ticker is first field showing
  22.   ECHO NORMAL
  23.   PROMPT "Real-time stock feed.", "Press any key to quit."
  24.   NStocks = NRECORDS("Price")                ; How many stocks to display?
  25.   IF (MOD(NStocks, 22) <> 0)                 ; we can fit 22 stocks on a screen
  26.     THEN NScreens = INT(NStocks / 22) + 1    ;   need extra screen for spillover
  27.     ELSE NScreens = NStocks / 22             ;   no spillover stocks
  28.   ENDIF
  29.  
  30.   WHILE (NOT CHARWAITING())                  ; if user types anything, leave
  31.     IF (NScreens > 1)                        ; only use ShowNSleep if more than 1 screen
  32.       THEN 
  33.         ShowNSleep("Down", NScreens)
  34.         ShowNSleep("Up", NScreens)
  35.       ELSE SleepRefresh()                    ; update the information on single screen
  36.     ENDIF
  37.   ENDWHILE
  38.  
  39. ; To get here, user must have typed a character.
  40.  
  41.   ECHO OFF                                  ; no more updating needed
  42.   i = GETCHAR()                             ; gobble up the character typed
  43.   CLEARALL                                  ; clear the workspace
  44. ENDPROC
  45.  
  46. ; ShowNSleep steps through the Main Board screens one at a time,
  47. ; using SleepRefresh to pause and refresh the information displayed.
  48.  
  49. PROC ShowNSleep(Direction, TotScreen)
  50.   FOR i FROM 1 TO TotScreen - 1       ; For each screen we have to display:
  51.     IF (CHARWAITING())                ;   make sure user didn't ask to leave,
  52.       THEN RETURN
  53.     ENDIF
  54.     SleepRefresh()                    ;   display and update the information,
  55.     IF (Direction = "Up")
  56.       THEN PGUP                       ;   move to previous page if we're heading back,
  57.       ELSE PGDN                       ;   move to next page if we're heading forward,
  58.     ENDIF
  59.   ENDFOR
  60. ENDPROC
  61.  
  62. ; SleepRefresh performs a 3-second SLEEP with an explicit table refresh
  63. ; in the middle of the period.
  64.  
  65. PROC SleepRefresh()
  66.   SLEEP 1500               ; pause for 1.5 seconds
  67.   REFRESH                  ; force an update of the information
  68.   SLEEP 1500               ; pause for 1.5 more seconds
  69. ENDPROC
  70.