AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

need an urgent help on number formats

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Benny-D



Joined: 29 Feb 2008
Posts: 865

PostPosted: Sat Apr 26, 2008 8:44 pm    Post subject: need an urgent help on number formats Reply with quote

Please help me with this. I need the answer urgently.

What should I do in this script so that before the number
of loop iterations exceeds 999, the message box would
show me a number in 3-digits format (like 005, 007, 025,
100, 120, 759, 843, etc. ), but after the number of iterations
exceeds 999, it would show me a 4-digit number (like 1000,
1001, 1010, 2000, 2067, 5940, 6789, 7432, 7656, 8092,
9991, etc.)

Code:
Numb:= 0
 Loop, 9999
{
Numb:= Numb+1
Msgbox, %Numb%
}
Back to top
View user's profile Send private message
Leon



Joined: 27 Aug 2007
Posts: 179

PostPosted: Sat Apr 26, 2008 9:35 pm    Post subject: Reply with quote

Try this
Code:
Numb:= 0
 Loop, 9999
{
Numb:= Numb+1
StringLen, NumbLen, Numb
If NumbLen = 1
Numb = 00%Numb%
If NumbLen = 2
Numb = 0%Numb%
Msgbox, %Numb%
}
Back to top
View user's profile Send private message
Benny-D



Joined: 29 Feb 2008
Posts: 865

PostPosted: Sun Apr 27, 2008 1:47 am    Post subject: Reply with quote

Leon, thank You! You have saved me!!! It works.

Now I wonder if it's possible to do it "appropriately" using SetFormat command?
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Sun Apr 27, 2008 2:27 am    Post subject: Reply with quote

You can do it a little simpler:
Code:
x = 3
MsgBox % SubStr(x+1000,-2)
With Setformat:
Code:
SetFormat Float, 03
x = 9
MsgBox % x+.0
Back to top
View user's profile Send private message
Benny-D



Joined: 29 Feb 2008
Posts: 865

PostPosted: Sun Apr 27, 2008 3:25 am    Post subject: Reply with quote

Laszlo, thank You very much!!!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group