Post Reply 
71B: DISP, KEY$, and keyboard buffer
04-23-2021, 01:13 AM
Post: #5
RE: 71B: DISP, KEY$, and keyboard buffer
.
Hi, Dave:

(04-23-2021 12:24 AM)Dave Britten Wrote:  Yeah, display something on the screen, then stop and wait until a key is pressed before continuing. DELAY 8,8 makes DISP work that way, but you have to manually clear the keyboard buffer with KEY$ afterward, or whatever key you pressed will perform its normal function as soon as you get to something like INPUT which reads the keyboard.

I've found myself in this exact situation oftentimes, when wanting to pause long outputs to be able to read/write them down, and the best solution I've found so far is:

- set DELAY INF
- when something gets displayed, the DELAY will stop the program allowing you to read the output for as long as you want
- press the Space key, [SPC], *not* [END LINE], the program will continue
- proceed to do the same for all other output lines, always pressing [SPC] to continue program execution

- if an INPUT then executes, a *single* space will appear as the first character, not multiple spaces

This causes no harm for numeric input, because the INPUT statement trims leading and trailing spaces, so just key in your number or numbers and press [END LINE] as usual to accept them.

If INPUT is asking for a string variable, the space appears as well as the first character but this doesn't cause any harm either, just key in the characters of your string and the initial space *won't* be added to them.

Examples:

1 DELAY INF @ DISP "TEST 1" @ DISP "TEST 2" @ INPUT X @ DELAY 0,0

or

1 DELAY INF @ DISP "TEST 1" @ DISP "TEST 2" @ INPUT X$ @ DELAY 0,0

Try them and see that your two presses of the [SPC] key result in just one single space as the first character in both inputs, which is irrelevant for the numeric input and doesn't get stored as part of the string variable for the string input.

The bottom line: using [SPC] instead of [END LINE] or any other key will mostly achieve what you want.

One caveat: should you use LINPUT instead of INPUT to enter a verbatim string into a string variable, then the space *will* be added as the first character in the string. However LINPUT is very rarely used and you can always add a TRIM afterwards.

V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: 71B: DISP, KEY$, and keyboard buffer - Valentin Albillo - 04-23-2021 01:13 AM



User(s) browsing this thread: 1 Guest(s)