New topic: Removing individual characters from string.
<http://forums.realsoftware.com/viewtopic.php?t=33301> Page 1 of 1 [ 12 posts ] Previous topic | Next topic Author Message waveuponwave Post subject: Removing individual characters from string.Posted: Wed Apr 07, 2010 5:55 pm Joined: Fri Jan 29, 2010 12:39 pm Posts: 133 Location: Virginia U.S.A. I am using this code in a timer to animate a static text ticker. It goes from right to left and when it reaches a set position I would like for the static text to disappear one character at a time like it was scrolling off screen. How would I do this? Thanks. Code: // Speed of the Ticker// Tickertxt.Left = Tickertxt.Left -1 // Where to begin again// If Tickertxt.Left = -TickerEnd +425 Then ' Delete individual character one at a time until all gone ??? ' Auto increment array index tCount = tCount + 1 ' If the number of ticker rows is less than the auto increment array index then reset to 0 and start over If tCount >= tRows Then tCount = 0 End ' Refresh Ticker Data Call TickerFill //Set starting point// Tickertxt.Left = 1200 end _________________ RB2010r1 Pro on Win 7 I promise to help if I ever learn how to help myself. Top timhare Post subject: Re: Removing individual characters from string.Posted: Wed Apr 07, 2010 6:29 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 7544 Location: Portland, OR USA Stop decrementing Tickertxt.Left when you start removing characters. Code:if Tickertxt.Left> -TickerEnd +425 then Tickertxt.Left = Tickertxt.Left - 1 else // remove characters Tickertxt.Text = mid(Tickertxt.Text, 2) if Tickertxt.Text= "" then // reset Text and Left end end Top waveuponwave Post subject: Re: Removing individual characters from string.Posted: Wed Apr 07, 2010 6:45 pm Joined: Fri Jan 29, 2010 12:39 pm Posts: 133 Location: Virginia U.S.A. Thanks for the reply Tim but it doesn't seem to remove the characters for me it just starts over like it did before. I have a text field on left of the ticker at the +425 position. When the text reaches that I need it to disappear like it was reaching the far left side of the program. I'm not sure what I am missing in your code example? _________________ RB2010r1 Pro on Win 7 I promise to help if I ever learn how to help myself. Top timhare Post subject: Re: Removing individual characters from string.Posted: Wed Apr 07, 2010 7:01 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 7544 Location: Portland, OR USA I'm not sure what you're doing with "-TickerEnd + 425", but using a fixed position such as 20 works for me. Step through the code in the debugger and watch what happens. Top waveuponwave Post subject: Re: Removing individual characters from string.Posted: Wed Apr 07, 2010 7:03 pm Joined: Fri Jan 29, 2010 12:39 pm Posts: 133 Location: Virginia U.S.A. Rather than just blinking out and starting over at the right what I am trying to do is have it disappear one character at a time. I'm sorry if I am not explaining it well to you. _________________ RB2010r1 Pro on Win 7 I promise to help if I ever learn how to help myself. Top timhare Post subject: Re: Removing individual characters from string.Posted: Wed Apr 07, 2010 7:04 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 7544 Location: Portland, OR USA No, you explained it very well. The code I posted does exactly that in my test app. (Using a fixed position for the end point.) Last edited by timhare on Wed Apr 07, 2010 7:05 pm, edited 1 time in total. Top waveuponwave Post subject: Re: Removing individual characters from string.Posted: Wed Apr 07, 2010 7:04 pm Joined: Fri Jan 29, 2010 12:39 pm Posts: 133 Location: Virginia U.S.A. Code that generates the ticker from the database. Code: Dim p as picture = Newpicture(1,1,1) Dim g as Graphics = p.Graphics g.TextFont = TickerTxt.TextFont g.TextSize = TickerTxt.TextSize g.Bold = TickerTxt.Bold //Get Ticker width// tWidth = g.stringwidth(s) //Draw Ticker text// Tickertxt.text = Ticker //Set Ticker end// TickerEnd = tWidth //Set Ticker width// Tickertxt.Width = TickerEnd _________________ RB2010r1 Pro on Win 7 I promise to help if I ever learn how to help myself. Top waveuponwave Post subject: Re: Removing individual characters from string.Posted: Wed Apr 07, 2010 7:05 pm Joined: Fri Jan 29, 2010 12:39 pm Posts: 133 Location: Virginia U.S.A. Code:(s) is the Ticker array. _________________ RB2010r1 Pro on Win 7 I promise to help if I ever learn how to help myself. Top waveuponwave Post subject: Re: Removing individual characters from string.Posted: Wed Apr 07, 2010 7:10 pm Joined: Fri Jan 29, 2010 12:39 pm Posts: 133 Location: Virginia U.S.A. Ok I got it working. Thanks Tim, as always thanks so much! _________________ RB2010r1 Pro on Win 7 I promise to help if I ever learn how to help myself. Top waveuponwave Post subject: Re: Removing individual characters from string.Posted: Wed Apr 07, 2010 8:25 pm Joined: Fri Jan 29, 2010 12:39 pm Posts: 133 Location: Virginia U.S.A. Tim is there any way to slow down the removal of the characters to match the speed of the ticker? _________________ RB2010r1 Pro on Win 7 I promise to help if I ever learn how to help myself. Top waveuponwave Post subject: Re: Removing individual characters from string.Posted: Wed Apr 07, 2010 9:40 pm Joined: Fri Jan 29, 2010 12:39 pm Posts: 133 Location: Virginia U.S.A. I tried adjusting the Timer periods when it starts removing characters. That helped a bit but it's a little jerky still. Any ideas? _________________ RB2010r1 Pro on Win 7 I promise to help if I ever learn how to help myself. Top timhare Post subject: Re: Removing individual characters from string.Posted: Thu Apr 08, 2010 1:24 am Joined: Fri Jan 06, 2006 3:21 pm Posts: 7544 Location: Portland, OR USA You could use a canvas instead of a static text and draw the string in canvas paint instead of moving the statictext. Moving the statictext control does seem to be much slower than redrawing the text (by changing statictext.text). Add a canvas the entire width of the area you are scrolling the text in and use a window property to hold the current X value. Start at Canvas Width and decrement to 0. When you reach zero, remove one character at a time, then start back at canvas.width. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 12 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
