DysFunction Posted February 5, 2013 Share Posted February 5, 2013 Hey all, I had a few questions, I'm new to Autoit and programming in general, about a week in, I've written a fully functional script or program, most of the information I needed was from the wiki/help file and the forums so that was awesome. I'd like to read all files ending with *.txt in a directory and use regex to pull only certain data. for instance, the first column of numbers up to a comma. For example \(^[0-9]+\), Making this group 1, excluding the comma. Then sum all the returned values. This would be trivial in bash and I know autoit supports regex, could someone point me in the right direction? Also, Another newbie question, if I have a DLL file, for example imagesearch which I've used extensively, is it possible to port this to another programming language and use the same DLL but process the returned data in a method thats specific to the language? Say for example C#. Is there any books or tutorials etc that someone can recommend to get more 'up to speed' on these kind of things? Thanks, DysFunction Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 5, 2013 Moderators Share Posted February 5, 2013 DysFunction,Welcome to the AutoIt forum. I'd like to read all files ending with *.txt in a directoryThen you need _FileListToArray. That gets you an array of filenames which you can loop through with For...Next, using FileRead to get the content of the files. You can extract the data you require in several ways: StringRegExp and StringSplit could both do what you want. Could I gently point you to the Help file for more details? And you can easily search for other functions you might need within it. As to the DLL question, I leave the final word to others, but you should be able to call a DLL in any language. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
DysFunction Posted February 5, 2013 Author Share Posted February 5, 2013 So _FileListToArray to add all the file names I need, with StringRegExp to only get .txt files Then a For loop to go through and add all the values I need to an array. Then another for Loop to go through all the items in the array to sum them. That makes sense, is that correct, and a good way to approach it? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 5, 2013 Moderators Share Posted February 5, 2013 DysFunction,You do not need a regex to select only the .txt files - the function has a filter that will do that for you, as the Help file tells you (I did suggest that you look in there for more details). You would use the regex to extract the data from each file as you looped through the returned array. Why not try to code something yourself to see what you can come up with - we tend to work on the "teach a man to fish, not give him a fish" principle here. You know where we are if you run into problems. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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