Search code examples
qbasic

how to know the last printed text in QBasic


I want to know that how to get the last printed text in QBasic. Like if the program prints several lines, then how to get the last line printed.

Like this-

Print "aaaaaaa"
Print "bbbbbbb"

Then the program will get the last printed line i.e. bbbbbbb


Solution

  • Something like this maybe?

    str$ = "aaaaaaa"
    PRINT str$
    str$ = "bbbbbbb"
    PRINT str$
    PRINT "last printed line:"; str$
    

    Alternatively, as explained here, you can retrieve characters from screen memory by using PEEK at segment &HB800 , so something like this

    DEF SEG = &HB800
    mychar = PEEK(1) 'etc
    

    You'd have to keep track of on which line was last printed to know where exactly you need to PEEK, so that will probably get very complicated very quickly...

    For that reason I recommend you to rethink what it is exactly that you are trying to accomplish here because "screen scraping" like this is usually just a bad idea.