25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more...
Home   Projects   Up   Sitemap   Search   Blog   Forum+Chat   About Us   Privacy   Terms of Use   Feedback   FAQ   Images   Services   Ads   Donate   Humor

Simple QBASIC cooking timer sounds alarm when interval has elapsed

TIMER.BAS is a simple QBASIC program that works like a cooking timer. It sounds an alarm (beeps through the PC speaker) when the specified timing interval has elapsed.

For timing events within a C++ program, see stopwatch.htm.

REM TIMER.BAS    10/18/01
REM Copyright (C)2001 Steven Whitney.
REM Published under GNU GPL (General Public License) Version 3, with ABSOLUTELY NO WARRANTY.
REM Initially published by http://25yearsofprogramming.com.
REM Originally written for QBASIC.

CLS
PRINT "A simple timer program for cooking, etc."
PRINT
INPUT "Enter Timing Interval (in minutes): ", Interval
Interval = Interval * 60
GOSUB ResetTimer
ON TIMER(1) GOSUB TimeUpdate
TIMER ON
WHILE 1
    a$ = INKEY$
    IF a$ = CHR$(27) THEN PRINT "Done.": TIMER OFF: END
    IF a$ <> "" THEN GOSUB ResetTimer
WEND
END

TimeUpdate:
    Elapsed = TIMER - StartTime
    IF Elapsed >= Interval THEN
        LOCATE 3, 1: PRINT "Press Any Key to Resume Timing..."
        WHILE INKEY$ = ""
            SOUND 2000, 1
        WEND
        GOSUB ResetTimer
        Elapsed = TIMER - StartTime
    END IF
    Remaining = Interval - Elapsed
    CLS
    LOCATE 1, 1: PRINT "Time", "Seconds Remaining"
    LOCATE 2, 1: PRINT TIME$, Remaining
    LOCATE 4, 1: PRINT "ESC to exit.  Any other key resets timer."
    RETURN

ResetTimer:
    StartTime = TIMER
    RETURN

 

 

Valid HTML 4.01 Transitional Valid CSS
View content labeling at ICRA.
Copyright ©2008 Steven Whitney. Last modified 10/06/2008.