Prefilled INPUT - editing variables rather than retyping the whole thing

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
Post Reply
GrantsV
Posts: 2
Joined: Fri 07 Jun 2019, 12:13

Prefilled INPUT - editing variables rather than retyping the whole thing

Post by GrantsV » Fri 07 Jun 2019, 12:22

Hi,
Is there anyway to have INPUT prefilled with text so it can be edited?
For example, let say I'm editing a string variable and need to amend it, but don't want to retype it all in again.

CODE
=====
address1$ = "29 Stenson Road"
INPUT "Edit Address:", address1$

Console Output
=============
Edit Address: 29 Stenson Road<<<cursor is here ready for editing>>>
<I press delete 4 times and type "Street" and return, address1$ now = "29 Stenson Street">

Thanks!

Zaphod
Posts: 78
Joined: Sat 23 Jun 2018, 15:51

Re: Prefilled INPUT - editing variables rather than retyping the whole thing

Post by Zaphod » Fri 07 Jun 2019, 15:44

First, while there may be a way of prefilling the input buffer I don't know it.

However, there is a quick solution and that is to use the NOWAIT library, where similar functions are implemented in BBC BASIC and so is easy to modify.

If you look at FNinput in that library you can add a modified version of that function to your program. Don't modify the library!
If you took the LOCAL parameter a$ out of that list and instead made it a parameter as in DEF FNinput(a$) then what you are trying to achieve would seem to be possible. If you want to move the input cursor you can do it manually or if you want the cursor to be at the RH end initially then add C%=LENa$ before the REPEAT loop.

Z

p_m21987
Posts: 138
Joined: Mon 02 Apr 2018, 21:51

Re: Prefilled INPUT - editing variables rather than retyping the whole thing

Post by p_m21987 » Fri 07 Jun 2019, 19:22

Hello,

I'd just like to post the answer to the question about Pre-filling the INPUT buffer. The way to do it is to use *EXEC:

Code: Select all

      F% = OPENOUT(@tmp$ + "exec.tmp.txt")
      BPUT #F%, "This is some text to pre-fill the INPUT buffer";
      CLOSE #F%
      OSCLI "EXEC """ + @tmp$ + "exec.tmp.txt"""
      INPUT "Please enter something: " A$
I hope that's helpful to you.

PM

GrantsV
Posts: 2
Joined: Fri 07 Jun 2019, 12:13

Re: Prefilled INPUT - editing variables rather than retyping the whole thing

Post by GrantsV » Sat 08 Jun 2019, 17:27

Thanks! That works perfectly. Could you please explain how it works?

I can see that OSCLI is executing the bytes in the tmp file (the prefilled text), but how does this get to the screen?
And how is the prefilled text put to the screen AFTER the input, when the OSCLI statement is called before the input statement?

Thanks for your time and help.

p_m21987
Posts: 138
Joined: Mon 02 Apr 2018, 21:51

Re: Prefilled INPUT - editing variables rather than retyping the whole thing

Post by p_m21987 » Sun 09 Jun 2019, 11:57

Please refer to the BBC BASIC manual page on the *EXEC command:
http://www.rtrussell.co.uk/bbcwin/manua ... .html#exec
*EXEC

Accept console input from the specified file instead of from the keyboard. If the extension is omitted, .BBC is assumed. To specify a filename with no extension, add a final full-stop.

Post Reply