home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a009 / 6.ddi / SAMPLE.LIF / STATUS.PRG < prev    next >
Encoding:
Text File  |  1991-04-14  |  1.7 KB  |  69 lines

  1. /***
  2. *  Status.prg
  3. *
  4. *  Implements a moving status indicator that can be used during a batch process
  5. *  to indicate that the process is indeed underway.
  6. *
  7. *  Copyright (c) Nantucket Corporation, 1990.  All rights reserved.
  8. *  David R. Alison
  9. *
  10. *  Note: Compile with /N/W options
  11. */
  12.  
  13. #define ST_LEN     4                         // Length of status array
  14. #define ST_ROW     1                         // Status item display row
  15. #define ST_COL     2                         // Status item display column
  16. #define ST_COLOR   3                         // Status item color
  17. #define ST_CURRENT 4                         // Status item current position
  18.                                              // in aDisplay
  19. STATIC aDisplay := { "|", "/", "-", "\" }    // Status item display characters
  20.  
  21. /***
  22. *  StatusNew( [<nRow>], [<nCol>], [<cColor>] ) --> aStat
  23. *  Create a new Status array
  24. *
  25. */
  26. FUNCTION StatusNew( nRow, nCol, cColor )
  27.    LOCAL aStat[ ST_LEN ]
  28.  
  29.    aStat[ ST_ROW     ] := 0
  30.    aStat[ ST_COL     ] := 0
  31.    aStat[ ST_COLOR   ] := "W+/N"
  32.    aStat[ ST_CURRENT ] := 1
  33.  
  34.    IF nRow != NIL
  35.       aStat[ ST_ROW ] := nRow
  36.    ENDIF
  37.  
  38.    IF nCol != NIL
  39.       aStat[ ST_COL ] := nCol
  40.    ENDIF
  41.  
  42.    IF cColor != NIL
  43.       aStat[ ST_COLOR ] := cColor
  44.    ENDIF
  45.  
  46.    RETURN (aStat)
  47.  
  48. /***
  49. *  StatusUpdate( <aStat> ) --> NIL
  50. *  Update screen with new Status position
  51. *
  52. */
  53. FUNCTION StatusUpdate( aStat )
  54.    LOCAL cOldColor
  55.  
  56.    cOldColor := SETCOLOR( aStat[ ST_COLOR ] )
  57.  
  58.    aStat[ ST_CURRENT ]++
  59.    IF aStat[ ST_CURRENT ] > 4
  60.       aStat[ ST_CURRENT ] := 1
  61.    ENDIF
  62.  
  63.    @ aStat[ ST_ROW ], aStat[ ST_COL ] SAY aDisplay[ (aStat[ ST_CURRENT ]) ]
  64.  
  65.    SETCOLOR( cOldColor )
  66.  
  67.    RETURN NIL
  68.  
  69.