BBC BASIC for Windows
« Controlling Input Time »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 9:50pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Controlling Input Time  (Read 160 times)
mrcamwin
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx Controlling Input Time
« Thread started on: Jan 30th, 2018, 3:46pm »

Hello all,

I'm new to this, so apologies if I have posted this in the wrong place etc.

I am running some code and need to use inkey$ to get some input from the user. I want to randomise the length of time the inkey$ will wait before returning control back to the program.

During the time the program is waiting for response from inkey$ I want to update some values in the program.

As I see it I can either "FOR NEXT" loop through the time interval, updating the levels and also asking for the inkey$(200) or I can take a date stamp at the beginning of the inkey$ statement and another at the end. Then update the levels on the time interval divided by some arbitary value (time interval - 9000 divided by arbitary value 1000 - means 9 updates to the levels.

The first option limits the available slot for the user to input a response which will make them feel like they have lost control

The second will see the levels update in a big jump rather than a regular small increment.

I hope this all makes sense.

My questions are

a) Which is the better option (my feeling in the second) ?
b) Is there another better way ?

Any ideas/ feedback most welcome

regards MRCAMWIN
User IP Logged

DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: Controlling Input Time
« Reply #1 on: Jan 30th, 2018, 5:00pm »

Hi,

Given recent arguments, I feel constrained to point out that you would get more expert advice at the "other" forum:

http://bbcbasic.conforums.com/

In the meantime....

I'm not sure I understand all your requirements, but would something like this do what you want?
Code:
starttime%=TIME
timeint%=100+RND(500): REM wait for at least 1 second, and up to 6
q$=""
  REPEAT
    REM Do your other stuff here
    REPEAT
        t$=INKEY$(0)
        IF t$<>"" THEN PRINT t$;
        q$+=t$
    UNTIL t$=""
UNTIL TIME>starttime%+timeint%
PRINT
PRINT q$
 


That will wait for a random (but predetermined) time, collecting any typed input (and echoing it to the screen) into a string which you can process at the end. In the meantime, you can be doing something else where it says....

I'm assuming that you would only need to be off doing other stuff for a "reasonable" amount of time - not enough for a typist to fill the keyboard buffer. That probably means not more than a second or two, to be safe - but a second is a long time on a modern computer...

If you know you are only looking for (say) a single character, or you don't need to echo it, it could be simplified significantly, but the basic principle would be the same.

Best wishes,

D
User IP Logged

mrcamwin
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx Re: Controlling Input Time
« Reply #2 on: Feb 3rd, 2018, 07:43am »

Cheers D - I think you ve got the general idea. I ll play with the code a little more, thanks for the feedback.

regards MRI
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx Re: Controlling Input Time
« Reply #3 on: Feb 3rd, 2018, 2:08pm »

If you look in the TOOLS section there are many examples of keyboard input. (graphics tools with text input and display)
User IP Logged

I like making program generators and like reinventing the wheel
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls