 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Benny-D
Joined: 29 Feb 2008 Posts: 137
|
Posted: Sat Apr 26, 2008 8:44 pm Post subject: need an urgent help on number formats |
|
|
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 |
|
 |
Leon
Joined: 27 Aug 2007 Posts: 179
|
Posted: Sat Apr 26, 2008 9:35 pm Post subject: |
|
|
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 |
|
 |
Benny-D
Joined: 29 Feb 2008 Posts: 137
|
Posted: Sun Apr 27, 2008 1:47 am Post subject: |
|
|
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 |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Sun Apr 27, 2008 2:27 am Post subject: |
|
|
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 |
|
 |
Benny-D
Joined: 29 Feb 2008 Posts: 137
|
Posted: Sun Apr 27, 2008 3:25 am Post subject: |
|
|
| Laszlo, thank You very much!!! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|