home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Database / CLIPR503.W96 / STATUS.PR_ / STATUS.PR
Text File  |  1995-06-20  |  2KB  |  80 lines

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