🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by jr2921r Thu, 07 Jan 1993 15:16
Time restriction on data entry
#415
Author: jr2921r
Date: Thu, 07 Jan 1993 15:16
4 lines
700 bytes
I am writing a short program in QuickBasic 4.5 which requires the user to input
an answer to a question.  However, I only want to give the user a few seconds
to perform the data entry.  Is there an easy way to do this using the 
INPUT statement?
Re: Time restriction on data entry
#416
Author: John Hutchinson
Date: Thu, 07 Jan 1993 21:25
22 lines
1488 bytes
In article 1@acad.drake.edu, jr2921r@acad.drake.edu () writes:
>I am writing a short program in QuickBasic 4.5 which requires the user to input
>an answer to a question.  However, I only want to give the user a few seconds
>to perform the data entry.  Is there an easy way to do this using the 
>INPUT statement?

I don't believe you can use INPUT for this as it ties up the system until the
user presses Return.

Rather, I think you would have to write a routine for scanning the keyboard
inside your timer loop, exiting when a keystroke is detected.  This would
work fine for single character replies, but not if the user had to type in
multiple characters.

Any other ideas from someon else?

---

___________________________ John "HUTCH" Hutchinson _________________________
_________________ Fair Dinkum Technologies     Member - IAAD  _______________
________________ "No worries, mate... it's from Fair Dinkum!" _______________
____________ email: hutch@bellman.lanl.gov   GEnie: FAIR-DINKUM _____________
Re: Time restriction on data entry
#418
Author: David Steffen
Date: Thu, 07 Jan 1993 23:16
68 lines
2962 bytes
jr2921r@acad.drake.edu () writes:
>I am writing a short program in QuickBasic 4.5 which requires the user to 
>input an answer to a question.  However, I only want to give the user a few
>seconds to perform the data entry.  Is there an easy way to do this using
>the INPUT statement?

hutch@bellman.lanl.gov writes:
>I don't believe you can use INPUT for this as it ties up the system until the
>user presses Return.
>
>Rather, I think you would have to write a routine for scanning the keyboard
>inside your timer loop, exiting when a keystroke is detected.  This would
>work fine for single character replies, but not if the user had to type in
>multiple characters.
>
>Any other ideas from someon else?

I have never done precisely this, but frequently I need to accept
input while doing something else at the same time.  For this purpose,
the INKEY$ function of the Microsoft BASICs is the answer.  INKEY$
returns immediately, with the null string if nothing was typed, or
with the character typed.  Thus, just collect characters with INKEY$
until your time is up.  How you monitor the time is, I think, machine
dependent.  In a pinch, I suppose you could even substitute a FOR/NEXT
loop for the WHILE/WEND loop I describe below, hand calibrating the
number of passes through the loop to give the desired time.

This gets more or less complex, of course, depending on what you are
inputting, and if you want to allow editing (e.g. backspace).  In the
example below, I have assumed that you want to input a carriage return
delimited string, and that no editing is allowed.  (Editing is machine
specific, as it requires knowing the codes for removing characters and
backspacing on the screen - commonly <backspace - space - backspace>.)

Example code below:

FALSE% = 0: TRUE% = NOT FALSE%

finished% = FALSE%
buffer$ = ""
WHILE NOT finished%
        Temp$ = INKEY$
        IF Temp$ = CHR$(13) THEN
           finished% = TRUE%
        ELSE
	   buffer$ = buffer$ + INKEY$
        END IF
        {check the time}
        IF {you are out of time} THEN finished% = TRUE%
WEND

End Example Code:

I have not tested above code itself - it is derived from memory of
routines I have done like this (on the MAC - which shouldn't matter).
Use at your own risk.

Hope this is of some help.




-- 
David Steffen
Department of Cell Biology, Baylor College of Medicine, Houston TX 77030
Telephone = (713) 798-6655, FAX = (713) 790-0545
Internet = steffen@bcm.tmc.edu
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads