Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need help with writing a qbasic program for a home alarm system built off of qbasic. I need to setup that when the alarm is activated the computer asks for a passcode, but it needs to be a timed response so the alarm sounds after no input is entered. can anyone help me??
Dave

This program will do that:
DECLARE SUB SoundAlarm ()
DECLARE FUNCTION GetPassword$ ()
CLS
pasd$ = GetPassword$
PRINT pasd$
ENDFUNCTION GetPassword$
LF$ = CHR$(10)
CR$ = CHR$(13)
SP$ = CHR$(32)
DL$ = CHR$(127)
Password$ = ""
AlarmDelay = 5
Timeout = TIMER + AlarmDelay
OutOfTime% = 0
DO
CH$ = INKEY$
REM Allow only prinable characters for password
IF CH$ > SP$ AND CH$ < DL$ THEN
PRINT "*";
Password$ = Password$ + CH$
END IF
REM Out of time with no input for password
IF TIMER > Timeout AND Password$ = "" THEN
OutOfTime% = 1
END IF
LOOP UNTIL CH$ = LF$ OR CH$ = CR$ OR OutOfTime%
= 1
IF OutOfTime% = 1 THEN
PRINT "Alarm Sounded !!!"
DO
CH$ = INKEY$
CALL SoundAlarm
LOOP UNTIL CH$ <> ""
END IF
GetPassword = Password$
END FUNCTIONSUB SoundAlarm
FOR I% = 440 TO 900 STEP 5
SOUND I%, I% / 1000
NEXT I%
END SUB

Thanks for your help. My only problem is, the alarm won't sound if input is being entered. It pauses the whole program while the input is entered. I basically need to have a timed input. Does this make any sense?
-Dave

![]() |
Please help with c on bow...
|
Games Programming
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |