Sample of a scrolling screenby Solitaire (Login Solitaire1)S 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 randnum AS INTEGER, x AS INTEGER, y AS INTEGER DIM ch AS STRING, E AS STRING DIM charow(25) AS STRING CLS 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 NEXT x 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); NEXT x LOCATE 1, 20 PRINT "Press Enter to start scrolling..."; INPUT "", E$ CLS 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 LOOP LOOP WHILE INKEY$ = "" SYSTEM ----------------------------------------- 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 |
| Response Title | Author and Date |
| Variation of scrolling sample | Solitaire on Dec 2 |
| *You can type < and > for < and > | on Dec 3 |