home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************/
- /* */
- /* Demo of how to use timer-based functions in SALT scripts, */
- /* like in this simple stopwatch. */
- /* */
- /* Copyright 1995 deltaComm Development, Inc. */
- /* */
- /****************************************************************/
-
-
- main()
- {
- int t, tu, finit;
- tu = finit = 0;
-
- prints("Press any key to start timer.");
- inkeyw();
-
- t = timer_start(100); // Start with a 10 second count
-
- alarm(1);
- status_wind("And they're off!", 5); // Alert user that timer is started
- prints("Press a key to halt timer.");
- while (not finit) // set up a loop, seemingly endless
- {
- if (inkey()) // if the user presses a key, then
- finit = 1; // set "finit" to true so loop ends
-
- if (tu ^ time_up(t)) // Check for elapsed timer
- {
- tu = time_up(t); // Disable the elapsed timer msg
- prints("Some time today?..."); // if the timer's up.
- playwave("jeop.wav"); // Here's our host, Alex Trebeck!
- }
- // tone((t*5)+100, 1); // Uncomment for a noiser timer
- }
-
- printsc("That was "); // Show user how much time elapsed
- tu=timer_total(t);
- printn(tu);
- prints(" tenths of a second.");
-
- timer_restart(t, 0); // restart timer where it left off
- prints("One more time(r). <g>"); // and go again....
-
- inkeyw(); // Wait for keypress
-
- printsc("Total time: ");
- printn(tu+timer_total(t));
- prints(" tenths of a second.");
-
- timer_free(t); // Free timer for use by
- // another application
-
- t=curtime();
-
- prints(); // Finally, do a little manipulation
- printsc("Time is: "); // on the output of "curtime" to
- printn(thour(t)); // display the current time and date
- printsc(":"); // on screen in a nice format.
- if (tmin(t)<10) printsc("0");
- printn(tmin(t));
- printsc(":");
- if (tsec(t)<10) printsc("0");
- printn(tsec(t));
- prints();
- printsc("Date: ");
- printn(tmonth(t));
- printsc("-");
- printn(tday(t));
- printsc("-");
- printn(tyear(t));
- prints();
-
- }
-