### Author Topic: Problem with scrolling text thingy  (Read 80 times)

#### Gorlock

• Sr. Member
• Posts: 337
##### Problem with scrolling text thingy
« on: November 15, 2012, 02:27:58 PM »
Hi, I have been working on a music player and I can't figure out how to solve this problem. I want the name, if too large for the space, to scroll indefinitely about the space. When you run the program it works once but then it jumps back to the beginning. It works when you uncomment the indicated line, minus the indefinitely part. I could continue to add album\$ and SPACE\$ to the end of it but that could lead to memory issues and also just isnt a good way to go about it.

How can I get it to scroll fluently?

Code: [Select]
`SCREEN 12album\$ = "example album name"b1x = 409b1y = 17b2x = 511b2y = 119DO    _LIMIT 32    ticker& = ticker& + 1    IF ticker& MOD 16 = 0 THEN ticker2& = ticker2& + 1    GOSUB trunkalbum    _PRINTSTRING ((b1x + (((b2x - b1x) - (LEN(dispalbum\$) * 8)) / 2)), b1y - 16), dispalbum\$LOOPtrunkalbum:room = INT(((b2x - b1x) / 8))IF LEN(album\$) <= room THEN    dispalbum\$ = album\$ELSE    dispalbum\$ = album\$ + SPACE\$(INT((room / 2)))    ' dispalbum\$ = album\$ + SPACE\$(INT((room / 2))) + album\$ + SPACE\$(INT((room / 2)))                  uncomment this line for second example    ' adddispalbum\$ = SPACE\$(INT((room / 2))) + album\$    aticker = ticker2& MOD LEN(dispalbum\$)    dispalbum\$ = MID\$(dispalbum\$, aticker, room)    IF LEN(dispalbum\$) < room THEN dispalbum\$ = dispalbum\$ + SPACE\$(INT((room - LEN(dispalbum\$))))END IFRETURN`

#### SMcNeill

• Hero Member
• Posts: 2414
##### Re: Problem with scrolling text thingy
« Reply #1 on: November 15, 2012, 03:22:36 PM »

Code: [Select]
`SCREEN 12DIM album AS STRINGalbum = "Steve Rocks!  Hurrah!!  He's Awesome"displaylimit = 20: displaymethod = 1l = LEN(album)IF l < displaylimit THEN album = album + SPACE\$(displaylimit - l): l = displaylimitDO    _LIMIT 10    displaycounter = displaycounter + 1    IF displaymethod = 1 THEN        text\$ = SPACE\$(displaylimit - displaycounter) + LEFT\$(album\$, displaycounter)        IF displaylimit - displaycounter = 1 THEN displaycounter = 0: displaymethod = 2    ELSEIF displaymethod = 2 THEN        text\$ = MID\$(album\$, displaycounter, displaylimit)        IF displaycounter + displaylimit > l + 1 THEN displaycounter = 1: displaymethod = 3    ELSE        text\$ = RIGHT\$(album, displaylimit - displaycounter) + SPACE\$(displaycounter)        IF displaylimit - displaycounter = 0 THEN displaymethod = 1: displaycounter = 0    END IF    _PRINTSTRING (100, 100), text\$LOOP UNTIL INKEY\$ <> ""`
« Last Edit: November 15, 2012, 03:28:40 PM by SMcNeill »
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

#### Gorlock

• Sr. Member
• Posts: 337
##### Re: Problem with scrolling text thingy
« Reply #2 on: November 15, 2012, 03:46:09 PM »
Thank you Steve

But i want more of a continuous scroll where one doesn't completely disappear before the next one begins to appear. After a bit of modification to my code I got that output:

Code: [Select]
`SCREEN 12album\$ = "example album name"b1x = 409b1y = 17b2x = 511b2y = 119DO    _LIMIT 32    ticker& = ticker& + 1    IF ticker& MOD 16 = 0 THEN ticker2& = ticker2& + 1    GOSUB trunkalbum    _PRINTSTRING ((b1x + (((b2x - b1x) - (LEN(dispalbum\$) * 8)) / 2)), b1y - 16), dispalbum\$LOOPtrunkalbum:room = INT(((b2x - b1x) / 8))IF LEN(album\$) <= room THEN    dispalbum\$ = album\$ELSE    dispalbum\$ = album\$ + SPACE\$(INT((room / 2)))    aticker = ticker2& MOD LEN(dispalbum\$)    makedispalbum\$ = ""    FOR makedispalbum = aticker TO (aticker + room)        IF makedispalbum > LEN(dispalbum\$) THEN makedispalbum\$ = makedispalbum\$ + MID\$(dispalbum\$, (makedispalbum - LEN(dispalbum\$)), 1)        makedispalbum\$ = makedispalbum\$ + MID\$(dispalbum\$, makedispalbum, 1)    NEXT makedispalbum    dispalbum\$ = makedispalbum\$END IFRETURN`

#### SMcNeill

• Hero Member
• Posts: 2414
##### Re: Problem with scrolling text thingy
« Reply #3 on: November 15, 2012, 03:56:43 PM »
So you want it like this  (give or take -- add a few spaces to the end if you want a break at least in there for a small gap);

Code: [Select]
`SCREEN 12DIM album AS STRING, albumdisplay AS STRINGDIM displaygap AS STRING * 5album = "Steve Rocks!  Hurrah!!  He's Awesome"displaylimit = 20: displaymethod = 1l = LEN(album)IF l < displaylimit THEN    albumdisplay = album + SPACE\$(displaylimit - l): l = displaylimitELSE    albumdisplay = album + displaygap    l = l + len(displaygap)END IFDO    _LIMIT 10    displaycounter = displaycounter + 1    IF displaymethod = 1 THEN        text\$ = SPACE\$(displaylimit - displaycounter) + LEFT\$(albumdisplay, displaycounter)        IF displaylimit - displaycounter = 1 THEN displaycounter = 0: displaymethod = 2    ELSEIF displaymethod = 2 THEN        text\$ = MID\$(albumdisplay, displaycounter, displaylimit)        IF displaycounter + displaylimit > l + 1 THEN displaycounter = 1: displaymethod = 3    ELSE        text\$ = RIGHT\$(albumdisplay, displaylimit - displaycounter) + LEFT\$(albumdisplay, displaycounter)        IF displaylimit - displaycounter = 0 THEN displaymethod = 2: displaycounter = 0    END IF    _PRINTSTRING (100, 100), text\$LOOP UNTIL INKEY\$ <> ""`
Just change displaygap to the number of spaces you want between the start scroll and the finish scroll.

Note, I left displaygap as a string, so you could set it to "....." if you want, or "*****", or any other sort of deliminator between the last letter and the first letter.
« Last Edit: November 15, 2012, 04:09:57 PM by SMcNeill »
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

#### SMcNeill

• Hero Member
• Posts: 2414
##### Re: Problem with scrolling text thingy
« Reply #4 on: November 15, 2012, 04:31:07 PM »
And if you'd prefer it as a SUB so you can call it and keep the code simple enough:

Code: [Select]
`SCREEN 12DIM album AS STRINGalbum = "Steve Rocks!  Hurrah!!  He's Awesome"DO    _LIMIT 10    DisplayAlbumTitle albumLOOP UNTIL INKEY\$ <> ""SUB DisplayAlbumTitle (album AS STRING)STATIC displaycounter, displaymethodDIM albumdisplay AS STRINGDIM displaygap AS STRING * 5displaylimit = 20l = LEN(album)IF l < displaylimit THEN    albumdisplay = album + SPACE\$(displaylimit - l): l = displaylimitELSE    albumdisplay = album + displaygap    l = l + LEN(displaygap)END IFdisplaycounter = displaycounter + 1IF displaymethod = 0 THEN    text\$ = SPACE\$(displaylimit - displaycounter) + LEFT\$(albumdisplay, displaycounter)    IF displaylimit - displaycounter = 1 THEN displaycounter = 0: displaymethod = 1ELSEIF displaymethod = 1 THEN    text\$ = MID\$(albumdisplay, displaycounter, displaylimit)    IF displaycounter + displaylimit > l + 1 THEN displaycounter = 1: displaymethod = 2ELSE    text\$ = RIGHT\$(albumdisplay, displaylimit - displaycounter) + LEFT\$(albumdisplay, displaycounter)    IF displaylimit - displaycounter = 0 THEN displaymethod = 1: displaycounter = 0END IF_PRINTSTRING (100, 100), text\$END SUB`
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files