The QBasic Forum      Other Subforums, Links and Downloads
  << Previous Topic | Next Topic >>Return to Index  

Scroll long instructions on bottom line of screen

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

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   
AuthorReply

(Login qb432l)
R

*Very nice -- works great, except Esc doesn't end it (had to Ctrl/Break to exit).

March 7 2009, 7:13 PM 

*

 
 Respond to this message   
Solitaire
(Login Solitaire1)
S

You have to wait for the message to finish scrolling before the Esc key will work.

March 8 2009, 3:26 PM 

You could try using INKEY$ inside the loop if you want it to end during the scroll.



    
This message has been edited by Solitaire1 on Mar 8, 2009 3:30 PM


 
 Respond to this message   
Solitaire
(Login Solitaire1)
S

Code adjusted to use INKEY$

March 8 2009, 3:55 PM 

I used E$ as the second argument in the sub, so you only have to press the Esc key once to stop.

==========================================================================
DECLARE SUB Scroll (msg AS STRING, E AS STRING)
DIM msg AS STRING, E 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$), E$)
LOOP UNTIL E$ = CHR$(27)
SYSTEM

SUB Scroll (msg AS STRING, E 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
    E$ = INKEY$
LOOP UNTIL circuit = N - 80 OR E$ = CHR$(27)
DO WHILE t + 2 >= TIMER: LOOP
PRINT LEFT$(startmsg$, 80);
VIEW PRINT
END SUB



    
This message has been edited by Solitaire1 on Mar 8, 2009 4:01 PM


 
 Respond to this message   

(Login qb432l)
R

*Yeah, that works great -- I love the "crawl" effect -- it's like CNN.

March 8 2009, 5:08 PM 

*

 
 Respond to this message   
MONTREALER
(no login)

Re: Scroll long instructions on bottom line of screen

April 2 2009, 8:36 AM 

SCREEN 12
DIM ms%(2295)

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. "

lenght% = LEN(msg$)

FOR position% = 1 TO lenght%

LOCATE 30, 1
PRINT MID$(msg$, position%, 80);

FOR offset% = 1 TO 8
GET (2, 465)-(639, 478), ms%
PUT (1, 465), ms%, PSET
NEXT

NEXT

 
 Respond to this message   
MONTREALER
(no login)

Updated

April 4 2009, 7:52 AM 

SCREEN 12
DIM ms%(2241)

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. "
lenght% = LEN(msg$)

LOCATE 1, 1
PRINT "Press any key to display the scrolling instruction line; Esc to end"
E$ = INPUT$(1)

WHILE k$ <> CHR$(27)

position% = 0

WHILE position% < lenght% - 80 AND k$ <> CHR$(27)

position% = position% + 1
k$ = INKEY$
LOCATE 30, 1
PRINT MID$(msg$, position%, 80);

FOR offset% = 1 TO 8
GET (2, 465)-(639, 478), ms%
PUT (1, 465), ms%, PSET
NEXT

WEND
IF k$ <> CHR$(27) THEN SLEEP 2
WEND

 
 Respond to this message   
Current Topic - Scroll long instructions on bottom line of screen
  << Previous Topic | Next Topic >>Return to Index  

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