Sample of a scrolling screen

by Solitaire (Login Solitaire1)

The following program will create a string array of rows filled with random characters. It will fill the screen with the arrays. Then a nested DO loop works with the MID$() function to break up the strings. It appears to scroll the rows to the left, wrapping the string to the right.

This works with rows of string up to 80 characters. It's a lot more tricky to get it to work with longer strings. But this will give you something to start with.


DIM charow(25) AS STRING
RANDOMIZE randnum           'fill screen with random characters
FOR x = 1 TO 25
   FOR y = 1 TO 80
        ch$ = CHR$(INT(RND * 95) + 32)  'select a random character
        charand$ = charand$ + ch$       'create string of random characters
    NEXT y
    charow$(x) = charand$    'fill each array row with string of characters
    charand$ = ""            'reinitialize string for a new row

FOR x = 2 TO 25    'fill screen with array of random characters
    LOCATE x, 1    'leave top line for instructions to user
   PRINT charow$(x);
LOCATE 1, 20
PRINT "Press Enter to start scrolling...";
INPUT "", E$
LOCATE 1, 20
PRINT "Press any key to stop...";
y = 1
DO                  'Screen will wrap from right edge to left
        y = y + 1               'starts with row 2
        IF y = 80 THEN y = 2    'goes up to right edge of screen
        FOR x = 2 TO 25         'fills rows to bottom of screen
            LOCATE x, 1         'one row at a time
            PRINT MID$(charow$(x), y, 80 - y + 1);  'left side of row
            PRINT MID$(charow$(x), 1, y - 1);       'right side of row
        NEXT x

        t = TIMER               'delay needed to see the scrolling action
        DO WHILE t + .1 )= TIMER                    'delay part of a second
            IF t ) TIMER THEN t = t - 86400

NOTE: Copy and paste code into Notepad and save as a .bas file instead of .txt. Due to this forum's inability to display the greater-than sign, I had to substitute ) for that symbol in the following two lines. Please make that correction when you paste the code into your program.

DO WHILE t + .1 )= TIMER
IF t ) TIMER THEN t = t - 86400

Posted on Dec 2, 2010, 5:37 PM

Respond to this message   

Return to Index

Response TitleAuthor and Date
Variation of scrolling sampleSolitaire on Dec 2
*You can type &lt; and &gt; for < and >Artelius on Dec 3

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