PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 21st, 2013, 07:03 PM
KingOfHeart KingOfHeart is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 117 KingOfHeart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 33 m 40 sec
Reputation Power: 5
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.

Reply With Quote
  #2  
Old February 21st, 2013, 08:03 PM
aeternus's Avatar
aeternus aeternus is offline
For POny!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Location: Amsterdam
Posts: 416 aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 4 h 56 m 43 sec
Reputation Power: 114
This may be to obvious, but why not use text-align:right on the container that holds the digets?
__________________
PHP Tutorial

Reply With Quote
  #3  
Old February 21st, 2013, 08:06 PM
KingOfHeart KingOfHeart is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 117 KingOfHeart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 33 m 40 sec
Reputation Power: 5
No such function for my custom language..I just need the math formula..feel free to make it look php just keep it simple.

Reply With Quote
  #4  
Old February 21st, 2013, 08:19 PM
aeternus's Avatar
aeternus aeternus is offline
For POny!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Location: Amsterdam
Posts: 416 aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level)aeternus User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 4 h 56 m 43 sec
Reputation Power: 114
Quote:
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.
Quote:
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 08:21 PM.

Reply With Quote
  #5  
Old February 21st, 2013, 08:27 PM
KingOfHeart KingOfHeart is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 117 KingOfHeart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 33 m 40 sec
Reputation Power: 5
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.

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Increase xval as string length decreases

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap