I'm trying to take the entire console text at the end of the program and save it as a string variable. Then after I will take the string variable and save it as a text document. What would be the best way to tackle this obstacle? Thank you!
Asked
Active
Viewed 67 times
4
-
1I honestly don't know if there's a way to do this other than the [`SCREEN` function](https://qb64.org/wiki/SCREEN_(function)). You would need to know the size of the screen in text columns and rows, and you may find the documentation for the [`SCREEN` statement](https://qb64.org/wiki/SCREEN) helpful. If you're using custom non-monospace fonts or [`_NEWIMAGE`](https://qb64.org/wiki/NEWIMAGE) instead of the legacy screen modes, you will need to deal with the fact that the screen width and height is measured in pixels rather than monospace character cells, which I do not know how to help with. – MemReflect Jun 10 '20 at 23:42
-
https://www.qb64.org/wiki/BSAVE you may start from here. – Sir Jo Black Jun 11 '20 at 12:33
-
@SirJoBlack Isn't that for saving images, not text? – MemReflect Jun 13 '20 at 03:25
-
Found a solution ... :) – Sir Jo Black Jun 15 '20 at 18:09
1 Answers
2
I think this solution might help to solve your question.
The Qbasic code below requires a text file to read, it reads and prints on the screen the first nine line of the file, then copies the contents of the first ten screen line in the second half of the console reading the chars from the screen memory.
SCREEN 0
INPUT "File name: ", fname$
OPEN fname$ FOR INPUT AS #1
x = 9
WHILE NOT EOF(1) AND x <> 0
INPUT #1, x$
PRINT x$
x = x - 1
WEND
CLOSE #1
PRINT "----------------------------------"
REM HERE THE PROGRAM READS THE SCREEN
LOCATE 12, 1
FOR y = 1 TO 10
FOR x = 1 TO 80
PRINT CHR$(SCREEN(y, x, 0));
NEXT x
NEXT y

Sir Jo Black
- 2,024
- 2
- 15
- 22