If a person composes a short program and hit's F5 or "run" the output will fit on the viewers screen.

I have composed a long program for homework purposes, and once I hit F5 or "run" I do not see the WHOLE program output. Only the bottom half. By hitting ANY button at that point, QBASIC redirects you back to the editing screen. In this case - How do I scroll though my screens output?

Dani AI

Generated

QBASIC's run window has no scrollback buffer. The IDE executes your code in a fixed-size text screen (typically 25 lines) and when the program finishes control returns to the editor — so long output will only show the last screenful. That is why only the bottom half is visible and why pressing a key drops you back to edit mode.

Two practical approaches that address this:

  • Insert paging inside the program. This is the idea suggested, but implemented robustly you keep a line counter and pause when you reach the page limit. Example pattern:
CONST LINES_PER_PAGE = 23

SUB PauseForKey
    PRINT
    PRINT "Press any key to continue..."
    DO: k$ = INKEY$: LOOP WHILE k$ = ""
END SUB

lineCount = 0
FOR i = 1 TO 200
    PRINT i
    lineCount = lineCount + 1
    IF lineCount >= LINES_PER_PAGE THEN
        CALL PauseForKey
        CLS
        lineCount = 0
    END IF
NEXT i

Put the counter check inside the loops that produce output so the program pauses every page.

  • Capture output to a file. was right to suggest saving everything. You can either run a compiled EXE and redirect at the shell, or have the program write directly:
OPEN "output.txt" FOR OUTPUT AS #1
PRINT #1, "Line of output"
' ... more PRINT #1, ...
CLOSE #1

If running on a modern machine, native QBASIC may not run; consider using QB64 or DOSBox so you have a resizable/scrollable console or an easy compiler (QB64 or background on QBasic: QBasic - Wikipedia).

Recommended Answers

All 4 Replies

You could 'pipe' the output to a text file: yourprogram.exe > output.txt Now all the output you had, will be in the txt-file

You could 'pipe' the output to a text file: yourprogram.exe > output.txt Now all the output you had, will be in the txt-file

But there should be a way to view it without leaving the program interface... right?

Yeah. Do it like in chunks. That would be the easy way out.

PRINT "As many lines as fits minus 2"
INPUT "Press Enter To Continue"
PRINT "More lines"

I don't think that will work as you think. Its a little complicated, but since you seem to know Basic, do you mind I f I send you the program? Then you could show me where you think I would insert that language, as I show you why it might not work... yes/No?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.