February 21st, 2013, 08:03 PM
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.
February 21st, 2013, 09:03 PM
This may be to obvious, but why not use text-align:right on the container that holds the digets?
February 21st, 2013, 09:06 PM
No such function for my custom language..I just need the math formula..feel free to make it look php just keep it simple.
February 21st, 2013, 09:19 PM
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 KingOfHeart
Anyway what I would do is in case the string gets shorter because you are subtracting numbers (instead of adding( aka outputting))
Originally Posted by kingofhearts
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:
new len = 8 * strlen(SpeedString) + 8;
Comments on this post
Last edited by aeternus; February 21st, 2013 at 09:21 PM.
February 21st, 2013, 09:27 PM
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.