QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

Updated continuous scroll with option to stop & start.

January 23 2010 at 12:33 PM
Solitaire  (Login Solitaire1)
S


Response to Code adjusted to use INKEY$

 

I added a STATIC Boolean variable to allow any key to start or stop the message from scrolling. It will scroll continuously, restarting from the beginning when done.


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 start or stop 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
STATIC onoff 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$
    IF E$ <> CHR$(27) AND E$ <> "" THEN
        onoff = NOT onoff
        IF onoff = -1 THEN SLEEP
    END IF
    IF circuit = N - 80 THEN circuit = 0
LOOP UNTIL E$ = CHR$(27)
VIEW PRINT
CLS
END SUB


 
 Respond to this message   
 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