Author Topic: Scrollable DOS Screen  (Read 55 times)

Scrollable DOS Screen
« on: March 15, 2019, 02:22:33 PM »
Is it possible to use/access the method a modern DOS computer uses to display large number of lines in the DOS window?

For example, in a dos window type "help" and a long help list is displayed. You can scroll up and down this list.

This would be very useful in the tools firmware I use to monitor my industrial cell phones.

Offline FellippeHeitor

  • QB64 Developer
  • LET IT = BE
Re: Scrollable DOS Screen
« Reply #1 on: March 15, 2019, 02:29:20 PM »
Start your program with:

Code: [Select]

Offline Pete

  • Cuz I sez so, varmint!
Re: Scrollable DOS Screen
« Reply #2 on: March 15, 2019, 03:02:05 PM »
Or do you mean just to scroll say 500 lines of text through a 25 line high window? Yes, that can be coded. Something like: FOR i = 1 to 500: PRINT i: NEXT and have a way to scroll back through those numbers would require a routine similar to like this...

Code: [Select]
WIDTH 80, 25 ' Standard window.
DIM myarray(500) AS STRING * 80 ' Screen width
FOR ii% = 1 TO 500
    myarray(ii%) = LTRIM$(STR$(ii%))
    PRINT myarray(ii%)

    _LIMIT 30
    b$ = INKEY$
    IF LEN(b$) THEN
        IF b$ = CHR$(27) THEN SYSTEM ' Quit.
        IF b$ = CHR$(0) + "H" AND ii% > 23 THEN
            ' scroll up
            ii% = ii% - 23: IF ii% < 24 THEN ii% = 24
            FOR j% = 23 TO 1 STEP -1
                PRINT myarray(ii% - j%)
        END IF
        IF b$ = CHR$(0) + "P" AND ii% < 500 THEN
            ' scroll down
            FOR j% = 1 TO 23
                IF ii% > 500 THEN EXIT FOR
                PRINT myarray(ii%)
                ii% = ii% + 1
        END IF

    END IF

Up and down conditions show two approaches to the math, but there are several others. You can also make routines that scroll one line at a time. In other words you could show a cursor and it would travel up and down, entry by entry, and only scroll the screen when it was going above or below the top or bottom visible line. Anyway, I wouldn't recommend this code, it's too simplistic and if using $CONSOLE:ONLY with _DEST _CONSOLE is all you need, that's even easier!