How to find out the last typed text in QBasic
Something like this maybe?
str$ = "aaaaaaa"
PRINT str$
str$ = "bbbbbbb"
PRINT str$
PRINT "last printed line:"; str$
Alternatively as described here , you can extract characters from screen memory using PEEK on the HB800 segment, so something like this
DEF SEG = &HB800 mychar = PEEK(1) 'etc
You will need to keep track of which line the last date was printed on to find out exactly where you need the PEEK, so this will probably be very difficult very quickly ...
For this reason, I recommend that you rethink what exactly you are trying to accomplish here, because "screen scraping" as usual is just a bad idea .
source to share
Given that the last line printed did not end with a semicolon, this code should do the trick:
FOR char.num = 1 TO 80
last.line$ = last.line$ + chr$(SCREEN(CSRLIN - 1, char.num))
NEXT char.num
PRINT "Content of last line printed to is:"; last.line$
Explanation: CSRLIN
Returns the current cursor line. SCREEN(y, x)
returns the ascii code of the character at position y, x (string, string) on ββthe screen. Each time a line that does not end with a semicolon is printed to the screen, it is printed on the current line (y position) of the cursor, which is then incremented by one.
source to share
I realize this question already has an accepted answer, but I have my own solution where instead of trying to figure out what PRINT
last PRINT
ed you are instead using your own PRINT
SUB
in this example MYPRINT
. While not perfect and it only takes strings (hence STR$(123
) and uses variables SHARED
that are not necessarily appropriate, it is better than calling in memory.
DECLARE SUB MYPRINT (text$)
DIM SHARED lastprint$
MYPRINT ("Hello, World!")
MYPRINT (STR$(123))
MYPRINT ("Hi Again")
MYPRINT (lastprint$)
SUB MYPRINT (text$)
PRINT (text$)
lastprint$ = text$
END SUB
Output:
Hello, World!
123
Hi Again
Hi Again
source to share