danielkza Posted February 2, 2008 Posted February 2, 2008 (edited) Try this: #include <file.au3> #include <array.au3> #include <Date.au3> $dirpath = "D:\Datatrack\";set the path for the folder where the data extraction files are $sfilter = "*.PRO"; set the filter for the files you want to extract data from $FileList = _FileListToArray($dirpath, $sfilter, 1);get the list of files you want to extract data from If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf $MA = 1 While $MA <= $FileList[0] $fd = StringLeft($FileList[$MA],8) if $fd < 20070802 Or $fd > 20070803 Then _ArrayDelete ($FileList, $MA) $FileList[0]-=1 ContinueLoop Else $MA+=1 EndIf WEnd _ArrayDisplay ($FileList) Edited February 2, 2008 by danielkza
andybiochem Posted February 2, 2008 Posted February 2, 2008 To loop through arrays while changing their size you must use While... Not true. Going through an array whilst deleting elements using a for loop is easy - I use it all the time - ...but you MUST go from back to front using -1 steps.... for $i = (UBound($array) - 1) to 1 step -1 Also, in my opinion, you're asking for trouble assuming dates are integers. Might not be too much of a problem in this case, but AutoIT has some amazing DATE functions that account for inconsistencies with our 4th dimension!! Just my opinions, no critisism intended - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
andybiochem Posted February 2, 2008 Posted February 2, 2008 Oops missed an EndIf in my example above... for $i = (UBound($array1) - 1) to 1 step -1 for $j = 1 to (UBound($array2) - 1) for $k = 1 to (UBound($array3) - 1) if $array1[$i] >10 And $array2[$j] <4 And $array3[$k] >100 then ; etc etc etc ;<STATEMENT> EndIf next next next - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
williamk Posted February 4, 2008 Author Posted February 4, 2008 williamk, did you try my code? does it not work? #include <file.au3> #include <array.au3> #include <Date.au3> $dirpath = "D:\Datatrack\";set the path for the folder where the data extraction files are $sfilter = "*.PRO"; set the filter for the files you want to extract data from $FileList = _FileListToArray($dirpath, $sfilter, 1);get the list of files you want to extract data from If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf $MA = $FileList[0] While $MA >= 1 $fd = StringLeft($FileList[$MA],8) MsgBox(4096, "emp detail records", "Number of emp detail records for profile is:" & $fd) $fdi = int($fd) ;MsgBox(4096, "emp detail records", "Number of emp detail records for profile is:" & $fdi) if $fdi < 20070802 or $fdi > 20070803 Then _ArrayDelete ($FileList, $MA) EndIf $MA = $MA - 1 WEnd _ArrayDisplay ($FileList) I think the problem with your code earlier is that you are indexing on $y instead of $x, and so you are actually skipping some values. Hey BlueBear. Yep your code does work. Thanks much. You were right about my getting the $y and $x confused. Only problem is that the 0 element for the array still shows as 121, which could mess me up later on in my code when I reference the array. I think I will have to use the Ubound step method as suggested below to fix that.
williamk Posted February 4, 2008 Author Posted February 4, 2008 (edited) Not true. Going through an array whilst deleting elements using a for loop is easy - I use it all the time - ...but you MUST go from back to front using -1 steps.... for $i = (UBound($array) - 1) to 1 step -1 Also, in my opinion, you're asking for trouble assuming dates are integers. Might not be too much of a problem in this case, but AutoIT has some amazing DATE functions that account for inconsistencies with our 4th dimension!! Just my opinions, no critisism intended Hey Andy, Thanks much for your input. I agree, converting date strings to integers for purposes of filtering is not the ideal. I just didn't know of any other way to do it. How do I reset the array so the 0 element shows the correct number of elements in the array? Edited February 4, 2008 by williamk
GEOSoft Posted February 4, 2008 Posted February 4, 2008 Hey BlueBear. Yep your code does work. Thanks much. You were right about my getting the $y and $x confused. Only problem is that the 0 element for the array still shows as 121, which could mess me up later on in my code when I reference the array. I think I will have to use the Ubound step method as suggested below to fix that.Ubound is the better way to go anyway. At least if current chatter is correct and using the [0] element to hold the element count may be phased out. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Simucal Posted February 4, 2008 Posted February 4, 2008 Ubound is the better way to go anyway. At least if current chatter is correct and using the [0] element to hold the element count may be phased out. I remember reading a dev discussion about this.. and I think their concensus was while they wanted to remove the [0] element holding size thing... they decided it would break too many scripts currently out there so they were going to leave it. That is last I heard. AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
GEOSoft Posted February 4, 2008 Posted February 4, 2008 (edited) I remember reading a dev discussion about this.. and I think their concensus was while they wanted to remove the [0] element holding size thing... they decided it would break too many scripts currently out there so they were going to leave it. That is last I heard.Since when did we start worrying about breaking scripts around here? I've had lots of scripts broken by "advancements" in AutoIt. I use the term "advancements" a bit loosely as well because I didn't see all of them that way. However disagreement makes the world go around and sometimes we just have to adjust. To quote a quote as posted in Chat "Resistance is futile." Edited February 4, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
andybiochem Posted February 5, 2008 Posted February 5, 2008 Hey Andy, Thanks much for your input. I agree, converting date strings to integers for purposes of filtering is not the ideal. I just didn't know of any other way to do it. How do I reset the array so the 0 element shows the correct number of elements in the array? Not tested, but I'd guess at: $array[0] = Ubound($array) - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
randallc Posted February 5, 2008 Posted February 5, 2008 Not tested, but I'd guess at: $array[0] = Ubound($array)oÝ÷ Ûú®¢×:yÊ'²+-z{ZºÚ"µÍÌÍØ^VÌHHXÝ[ ÌÍØ^JKL (traditionally, the counter element [0] has not been counted!) Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
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