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!
Prefilled INPUT - editing variables rather than retyping the whole thing
-
- Posts: 2
- Joined: Fri 07 Jun 2019, 12:13
-
- Posts: 78
- Joined: Sat 23 Jun 2018, 15:51
Re: Prefilled INPUT - editing variables rather than retyping the whole thing
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
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
-
- Posts: 177
- Joined: Mon 02 Apr 2018, 21:51
Re: Prefilled INPUT - editing variables rather than retyping the whole thing
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:
I hope that's helpful to you.
PM
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$
PM
-
- Posts: 2
- Joined: Fri 07 Jun 2019, 12:13
Re: Prefilled INPUT - editing variables rather than retyping the whole thing
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.
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.
-
- Posts: 177
- Joined: Mon 02 Apr 2018, 21:51
Re: Prefilled INPUT - editing variables rather than retyping the whole thing
Please refer to the BBC BASIC manual page on the *EXEC command:
http://www.rtrussell.co.uk/bbcwin/manua ... .html#exec
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.