mapoul Posted January 31, 2007 Share Posted January 31, 2007 My non-programming brain has been trying for the past couple of days to figure out the logic to end a loop that I've created. I've searched the forums and help files for ideas, but I haven't found anything that has worked for me yet. Here's the summary: I'm trying to copy text from Excel, move down one cell, copy that cell, etc. until I reach a blank (null) cell. So I tried to tell the loop to only run when StringLen(ClipGet) > 4 (all of my text strings are 10 or more, null cells appear to = 2). However, the loop doesn't stop once it copies the null cell, it just keeps going forever. I'm sure it's something simple that I just don't understand or a flaw in my logic, but I can't seem to figure it out. Any help is greatly appreciated. CODEHotKeySet("{ESC}", "MyExit") ShellExecute("Book1.xls","","C:\","open") WinActivate("Microsoft Excel - Book1.xls","") WinWaitActive("Microsoft Excel - Book1.xls","", 2) Global $clip=ClipGet() Global $len=StringLen($clip) Send("^c") While $len > 4 Sleep(1000) Send("^c") Sleep(1000) Send("{DOWN}") WEnd MsgBox(4096, "Done?", "Yes") Func MyExit() Exit EndFunc BTW, the Excel file just has company names in it: Cell A1=Continuous Computing Cell A2=Alcatel USA Cell A3=Nortel Networks Cell A4=blank (null) Thank you, mapoul Link to comment Share on other sites More sharing options...
BALA Posted January 31, 2007 Share Posted January 31, 2007 (edited) The code doesn't seem to have a way to redeclare the $lens variable. Since the $lens isn't being redeclared, it stays as less than 4 and your loop continues. Edited January 31, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 31, 2007 Moderators Share Posted January 31, 2007 As BALA Stated: While $len > 4 Sleep(1000) Send("^c") Sleep(1000) Send("{DOWN}") $len = StringLen(ClipGet()) WEnd Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Shevilie Posted January 31, 2007 Share Posted January 31, 2007 Well heres some $holder will now contain all whats clipped with a ; to seperate HotKeySet("{ESC}", "MyExit") ShellExecute("Book1.xls","","C:\","open") WinActivate("Microsoft Excel - Book1.xls","") WinWaitActive("Microsoft Excel - Book1.xls","", 2) Global $clip Global $len = 10 Global $holder = "" While $len > 4 Sleep(1000) Send("^c") Sleep(1000) Send("{DOWN}") $clip=ClipGet() $holder = $holder & ";" & $clip $len=StringLen($clip) WEnd MsgBox(0,0,$holder) MsgBox(4096, "Done?", "Yes") Func MyExit() Exit EndFunc Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
mapoul Posted January 31, 2007 Author Share Posted January 31, 2007 Thanks for the quick responses. It works great now. You're both gentlemen and scholars. mapoul Link to comment Share on other sites More sharing options...
Shevilie Posted January 31, 2007 Share Posted January 31, 2007 Well np Try the Autoit tutorial (its somewhere on the forum) Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit 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