home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / PDXOS2-1.ZIP / SAMPLE / BOARD.SC < prev    next >
Encoding:
Text File  |  1988-12-29  |  2.9 KB  |  71 lines

  1. ;SCRIPT:       BOARD.SC
  2. ;Version:      2.0
  3. ;Date:         27 April 1987
  4. ;
  5. ;
  6. ; The procedures in this script handle the display of the "main board,"
  7. ; the table of stocks shown with real-time updates. Since the table may
  8. ; be larger than one display screen in length, it is shown in "pages,"
  9. ; with each page being displayed for a short period of time before moving
  10. ; on to the next page.
  11. ;
  12. ; SeeBoard is the main procedure here, and controls the initial display
  13. ; of the "main board." It uses the ShowNSleep procedure to display
  14. ; additional pages of the board, if any.
  15.  
  16. PROC SeeBoard()
  17.   PRIVATE nstocks,nscreens,i
  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 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 need to use ShowNSleep if more than 1 screen
  32.       THEN
  33.         ShowNSleep("Down", nscreens)
  34.         ShowNSleep("Up", nscreens)
  35.       ELSE SleepRefresh()             ; Update the information on the 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.  
  43.   x = GETCHAR()                       ; Gobble up the character typed
  44.   CLEARALL                            ; Clear the workspace
  45. ENDPROC
  46.  
  47. ; ShowNSleep steps through the "main board" screens one at a time,
  48. ; using SleepRefresh to pause and refresh the information displayed.
  49.  
  50. PROC ShowNSleep(Direction, TotScreen)
  51.   FOR i FROM 1 TO TotScreen-1         ; For each screen we have to display
  52.     IF (CHARWAITING())                ; | - Make sure user didn't ask to leave
  53.       THEN RETURN                     ; |
  54.     ENDIF                             ; |
  55.     SleepRefresh()                    ; | - Display and update the information
  56.     IF (Direction = "Up")             ; |
  57.        THEN PgUp                      ; | - Move to previous page if we're heading back
  58.        ELSE PgDn                      ; | - Move to next page if we're heading forward through pages
  59.     ENDIF                             ; v
  60.   ENDFOR
  61. ENDPROC
  62.  
  63. ; SleepRefresh performs a 3 second SLEEP with an explicit table refresh
  64. ; in the middle of the period
  65.  
  66. PROC SleepRefresh()
  67.   SLEEP 1500               ; SLEEP for 1.5 seconds
  68.   REFRESH                  ; Force an update of the information
  69.   SLEEP 1500               ; SLEEP for 1.5 more seconds
  70. ENDPROC
  71.