#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    118
    Rep Power
    7

    Increase xval as string length decreases


    I'm using a custom language and just need a little math help. PHP is close to the language so I figured I'd post here.

    --------------------
    I'm outputting numbers to a string and everytime the string gets shorter, it moves all the numbers to the left(by 8 pixels).
    I need it to keep the same xval.
    My custom language allows "strlen" so I just need a formula that reads the string's length and keeps the number's in the same place.

    ------------------
    new len = 8 * strlen(SpeedString);
    ------------------

    Multiplying is incorrect because as the string gets larger is moves it a lot more to the right. Do I div, substract,..I forget.

    If you don't understand any of my language, then create the math formula in php.
  2. #2
  3. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    This may be to obvious, but why not use text-align:right on the container that holds the digets?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    118
    Rep Power
    7
    No such function for my custom language..I just need the math formula..feel free to make it look php just keep it simple.
  6. #4
  7. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    Originally Posted by KingOfHeart
    No such function for my custom language..I just need the math formula..feel free to make it look php just keep it simple.
    OK but how does the string gets shorter? are you subtracting? because this quotes implies you are adding number to a string.
    Originally Posted by kingofhearts
    I'm outputting numbers to a string and everytime the string gets shorter
    Anyway what I would do is in case the string gets shorter because you are subtracting numbers (instead of adding( aka outputting))
    knowing that each digits is 8 pixels long. Take the original string length multiplied by 8 if you take a number off 8 is added

    could look like this I guess:
    PHP Code:
    new len strlen(SpeedString) + 8

    Comments on this post

    • KingOfHeart agrees
    Last edited by aeternus; February 21st, 2013 at 09:21 PM.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    118
    Rep Power
    7
    You helped a bit, this formula works.

    24 - (8 * strlen(SpeedString));

    24 is the original length and I'm keeping it simple so I'm using the number 24 instead of using strlen for this part.

IMN logo majestic logo threadwatch logo seochat tools logo