rsugumar Posted March 11, 2008 Share Posted March 11, 2008 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 Link to comment Share on other sites More sharing options...
spudw2k Posted March 11, 2008 Share Posted March 11, 2008 $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. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
JusGellin Posted March 11, 2008 Share Posted March 11, 2008 (edited) Or $length = 4 For $x = 1 to 147 $num = StringRight("000" & $x,$length) ConsoleWrite($num & @CRLF) Next Edited March 11, 2008 by JusGellin Link to comment Share on other sites More sharing options...
JusGellin Posted March 11, 2008 Share Posted March 11, 2008 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now