# Scrolling Text via strlen help, quick and simple...

• 06-08-2006
SG57
Scrolling Text via strlen help, quick and simple...
Ok, i have a string im printing to the screen with say, co-ordinates of X = 240 Y = 136

I want it so if the text is over say, 29 characters, then scrol it left for every time i enter a character...

I thought, o a simple if statment saying if strlen(string) > 29 { blah blah, but it is in a loop to keep cheking if it truely is over 29... but it then moves the text over 7 pixles to teh left (thats the characters width by the way) and then again, then agin, since its in a loop...

Ive been messing with for loops for such a thing, but i still cant get it...

So could some one help me out towards getting this string to scroll left, 7 pixels left, for each extra character entered past the 29 th char mark?

Im going to continue messing with for loops until I can get an answer...
• 06-08-2006
whiteflags
> Im going to continue messing with for loops until I can get an answer...
Is that some sort of threat? :p
Have a peek at this thread it may give you what you are looking for.
• 06-09-2006
SG57
Thx, but no, thats cool and all (and im using it now) but i still need this done...

Im printing text to the Coordinates: x = 240, y=136

I need to subtract 7 from the X co-ordinate every time the string length of the string increases by 1, starting from if its over 29...

Along with amybe a timed scrolling, like scroll the text 1 pixel a ta a time, then once it reaches the end of the string via scrolling, reset it, which shouldnt be that har, which im working on now :)
• 06-09-2006
glo
Did you try something like
Code:

```        if (strlen(string) > 29)                 printf("%s",string+(strlen(string)-29));```
• 06-09-2006
glo
I now notice you wanted a more advanced scrolling.

Find a way to calculate how many times the string needs to be scrolled back by 7 characters (based on its length) and store it in a new integer.

Then use the printf function to begin printing where string and your new integer point to together.

If this is too vague let me know.
• 06-09-2006
SG57
Well ill take a look

This here
Code:

`int ActualWidth = 7 * (strlen(string));`
Is the actual length of the string pixel wise...

Im just going to mess around with stuff...

Maybe someone here could help me out while i test around to make this easier?