Jump to content

Recommended Posts

Posted

Hei.... I have a whole list of bitmap files to load one by one into a program that prints this bitmap file for me and pauses for an appropriate amount of time. The file numbers range from 000001-000147. Instead of having 3 while loops (one for 0-9,one for 10-99 and one for 100-147) and changing the number of leading zeroes, is there a way that I could have AutoIt count the numbers from 001-147? Like 001,002,003...099,100,...147? That way I would only need one whle loop. Below I have posted the code.

Thanks. :)

$time=1000

$i= 0

While $i<= 9

Send("^o")

WinWaitActive("Open")

$filename= "C:\3d-printing\Printer-calibration\Phantoms\scaling_phantom-4mil-00000"& $i &".bmp"

Send($filename,1)

;; Click on open:

ControlClick("Open", "", "[CLASSNN:Button2]")

$i=$i+ 1

Sleep($time)

;WinMenuSelectItem("COM1-scaling_phantom-4mil-00000"& $i &".bmp","","& File")

;

WEnd

$time=100

$i= 10

While $i<= 99

Send("^o")

WinWaitActive("Open")

$filename= "C:\3d-printing\Printer-calibration\Phantoms\scaling_phantom-4mil-0000"& $i &".bmp"

Send($filename,1)

;; Click on open:

ControlClick("Open", "", "[CLASSNN:Button2]")

$i=$i+ 1

Sleep($time)

;WinMenuSelectItem("COM1-scaling_phantom-4mil-00000"& $i &".bmp","","& File")

;

WEnd

$time=100

$i= 100

While $i<= 147

Send("^o")

WinWaitActive("Open")

$filename= "C:\3d-printing\Printer-calibration\Phantoms\scaling_phantom-4mil-000"& $i &".bmp"

Send($filename,1)

;; Click on open:

ControlClick("Open", "", "[CLASSNN:Button2]")

$i=$i+ 1

Sleep($time)

;WinMenuSelectItem("COM1-scaling_phantom-4mil-00000"& $i &".bmp","","& File")

;

WEnd

Posted

$length = 4

For $x = 1 to 147
    $num = $x
    While StringLen($num) < $length
        $num = "0" & $num
    WEnd
    msgbox(0,"",$num)
Next

Obviously you'll want to remove the msgbox, but that's just to show you the output.

Posted (edited)

Or

$length = 4
For $x = 1 to 147
    $num = StringRight("000" & $x,$length)
    ConsoleWrite($num & @CRLF)
Next
Edited by JusGellin
Posted

Or

$length = 4
For $x = 1 to 147
    $num = StringRight("000" & $x,$length)
    ConsoleWrite($num & @CRLF)
Next
spudw2k's code is better because it adjusts for any variable number of desired digits.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...