Progress.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Progress bar example for TIGCC
  2. // Define this to display the progress bar in a (large) window
  3. //#define USE_WINDOW_PB
  4. #define USE_TI89 // Compile for TI-89
  5. #define USE_TI92PLUS // Compile for TI-92 Plus
  6. #define USE_V200 // Compile for V200
  7. #define MIN_AMS 200 // Compile for AMS 2.00 or higher
  8. #include <tigcclib.h> // Include All Header Files
  9. // Main Function
  10. void _main(void)
  11. {
  12. short j;
  13. #ifdef USE_WINDOW_PB
  14. ST_PROGRESS_BAR spb = {NULL, {0, 0, 0, 0}, 0, 0, 100, 100, 0};
  15. WINDOW w;
  16. memcpy (&(spb.rect), ScrToWin (ScrRect), sizeof (WIN_RECT));
  17. spb.physwidth = spb.rect.x1 - spb.rect.x0 + 1;
  18. WinOpen (&w, &(spb.rect), WF_SAVE_SCR | WF_NOBORDER);
  19. spb.w = &w;
  20. #else
  21. ST_PROGRESS_BAR spb;
  22. ST_progressBar (&spb, 0, 100); // Create the progress bar in spb. low=0, high=100.
  23. // It will be created in the status line.
  24. #endif
  25. for (j = 0; j < 20; j++)
  26. {
  27. OSFreeTimer (USER_TIMER);
  28. OSRegisterTimer (USER_TIMER, 1);
  29. while (!OSTimerExpired (USER_TIMER)); // Wait a little...
  30. ST_progressIncrement (&spb, 1); // Increment the progress bar by 1/100.
  31. }
  32. ST_progressUpdate (&spb, 50); // Increment the progress bar up to 50/100.
  33. OSFreeTimer (USER_TIMER);
  34. OSRegisterTimer (USER_TIMER, 20);
  35. while (!OSTimerExpired (USER_TIMER)); // Wait for about 1 second...
  36. OSFreeTimer (USER_TIMER);
  37. ST_progressUpdate (&spb, 100); // Fill the progress bar entirely.
  38. GKeyIn (NULL, 0);
  39. ST_progressDismiss (&spb); // Remove the progress bar, redraw status line.
  40. #ifdef USE_WINDOW_PB
  41. WinClose (&w);
  42. #endif
  43. }