Thread: Scrolling Text via strlen help, quick and simple...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    45

    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...

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    > Im going to continue messing with for loops until I can get an answer...
    Is that some sort of threat?
    Have a peek at this thread it may give you what you are looking for.

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    45
    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

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    169
    Did you try something like
    Code:
    	if (strlen(string) > 29)
    		printf("%s",string+(strlen(string)-29));

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    169
    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.

  6. #6
    Registered User
    Join Date
    Jun 2006
    Posts
    45
    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?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick help needed on simple example
    By hiven in forum C Programming
    Replies: 6
    Last Post: 05-13-2009, 12:46 AM
  2. quick simple question regarding enums;
    By MegaManZZ in forum C++ Programming
    Replies: 4
    Last Post: 01-17-2008, 03:47 PM
  3. Quick question, should be simple to answer.
    By kabuatama in forum C Programming
    Replies: 4
    Last Post: 01-21-2006, 03:42 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Quick simple question
    By carrja99 in forum C++ Programming
    Replies: 3
    Last Post: 01-31-2003, 08:37 AM