QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

Scroll long instructions on bottom line of screen

March 7 2009 at 6:45 PM
Solitaire  (Login Solitaire1)
R

 
This subprocedure can be used when you have a complex program and need to show the user a lot of instructions.

The subprocedure may be called to scroll very long instructions at the bottom of the screen. I placed some text in a string variable named msg$. You can adjust the code to suit your preferences. The instructions may be placed in a text file. The file can be opened and read into the string variable or group of variables if it's longer than 256 characters.

You could put a different message at the bottom of the screen, or place the line telling the user to press a certain key to start the scrolling instructions.

I finished it up by waiting 2 seconds and replacing the bottom line with the beginning of the message. You could simply blank it out after a short wait, or put back the notice for the user to press a certain key to scroll the instructions again.

Notice that I used double parentheses around the ((msg$)) argument to call the sub. This passes the msg$ variable By Value instead of By Reference. It keeps the original value of the message and prevents it from becoming corrupted or growing longer with each new repeat.

===========================================================================

DECLARE SUB Scroll (msg AS STRING)
DIM msg AS STRING
msg$ = "This is a very long message that will scroll around. It will serve as instruction for using a software program and should stay on the bottom line. "
CLS
LOCATE 25, 1
PRINT LEFT$(msg$, 80);
DO
    LOCATE 1, 1
    PRINT "Press any key to display the scrolling instruction line; Esc to end"
    E$ = INPUT$(1)
    IF E$ <> CHR$(27) THEN CALL Scroll((msg$))
LOOP UNTIL E$ = CHR$(27)
END

SUB Scroll (msg AS STRING)
DIM startmsg AS STRING
DIM N AS INTEGER
N = LEN(msg)
DIM ch AS STRING
DIM circuit AS INTEGER
circuit = 0
startmsg$ = msg$
VIEW PRINT 25 TO 25
DO
    circuit = circuit + 1
    ch = MID$(msg$, 1, 1)
    msg$ = MID$(msg$, 2, N - 1) + ch
    PRINT LEFT$(msg$, 80);
    pause = .1
    t = TIMER
    DO WHILE t + pause >= TIMER: LOOP
LOOP UNTIL circuit = N - 80
DO WHILE t + 2 >= TIMER: LOOP
PRINT LEFT$(startmsg$, 80);
VIEW PRINT
END SUB


 
 Respond to this message   
Responses

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement  

Newbies usually go to www.qbasic.com and click on The QBasic Forum
Forum regulars have their own ways, which include The QBasic Community Forums