Ruud0209 Posted May 18, 2008 Share Posted May 18, 2008 Hi, I want to find the last, most recent, file in a directory, open it and read the first 12 (or x) lines skip the first 2 lines and use the 10 remaining lines to extract a certain string from them. (wich would be at array position 3 if used with the stringsplit function) I know this is possible but alas i have zero programming skills. (I do do have some read/copy/paste skills though) :-) I suppose it's a nobrainer for the gods out here so please if you can spare the time and help me a little on my way you will have my grattitude. tia Link to comment Share on other sites More sharing options...
monoceres Posted May 18, 2008 Share Posted May 18, 2008 (edited) Here's the first part, but I didn't understand how it should read the file. Maybe post an example file to show us how it look like? #include <File.Au3> $files=_FileListToArray(@DesktopDir,"*",1) Dim $latest, $latestdate=-1 For $i=1 To UBound($files)-1 $temp=FileGetTime($files[$i],1,1) If $latestdate=-1 Or $temp>$latestdate Then $latest=$files[$i] $latestdate=$temp EndIf Next MsgBox(0,"",$latest) Edited May 18, 2008 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Ruud0209 Posted May 19, 2008 Author Share Posted May 19, 2008 First of all, thanks a million for your input. Ok let's see, What I have now is this : #include <IE.au3> dim $oIE, $sInputBoxAnswer do ;If Not IsDeclared("sInputBoxAnswer") Then Local $sInputBoxAnswer $sInputBoxAnswer = InputBox("Who are you looking for ?","Please enter the name of the player you are searching","enter playername"," ","-1","-1","-1","-1") Select Case @Error = 0 If Not WinExists("Top Shark") Then $oIE = _IECreate ("www.pokerprolabs.com/TopShark/topshark.aspx?pokernetwork=1&playername=" & $sInputBoxAnswer ) Else _IENavigate($oIE ,"www.pokerprolabs.com/TopShark/topshark.aspx?pokernetwork=1&playername=" & $sInputBoxAnswer) EndIf Case @Error = 3 ;The InputBox failed to open Exit EndSelect until @error = 1 exit Wich is quite simple and functional but I want to create a gui with two extra buttons wich will either have you select a file or open the last created file automatically. The gui and the file select thing I can tackle and with your fine piece of code i'll be able to make the other button work too . Problem now is to parse the file correctly so that playernames are automatically extracted from the "seat" lines ( from the correct part) of the file. I think it might be better to have it parse the file from the last blank line to the end so i'll be able to get only players still on the table. An extra for the select file button would be to have all the players in an array for use in a listbox but thats for future additions to the program. As you can see, it is basically meant to function as a timesaver tool since all it is supposed to do is open a webpage with a playername as parameter and when automated it should refresh until all current players are listed. I added a handhistory example as attachment.latestHH.txt Link to comment Share on other sites More sharing options...
Ruud0209 Posted May 20, 2008 Author Share Posted May 20, 2008 *bump* Link to comment Share on other sites More sharing options...
monoceres Posted May 20, 2008 Share Posted May 20, 2008 Ok, here's my result. This will extract players from the text file. Each game is separated in the array with a empty string. Please try it and try to improve it yourself #include <File.Au3> #include <array.au3> Dim $players[1]=[0] $files=_FileListToArray(@DesktopDir,"*",1) Dim $latest, $latestdate=-1 For $i=1 To UBound($files)-1 $temp=FileGetTime($files[$i],1,1) If $latestdate=-1 Or $temp>$latestdate Then $latest=$files[$i] $latestdate=$temp EndIf Next $handle=FileOpen($latest,0) Do $temp=FileReadline($handle) If @error THen ExitLoop If StringLeft($temp,4)="seat" Then ReDim $players[Ubound($players)+1] $data=StringMid($temp,StringInStr($temp,":")+2,StringInstr(StringTrimLeft($temp,6),")")) $players[UBound($players)-1]=StringLeft($data,StringInStr($data," ")-1) EndIf Until False _ArrayDisplay($players) Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Ruud0209 Posted May 21, 2008 Author Share Posted May 21, 2008 Thanks a million !! I think I have enough to get me going so i'll go and try and make something of it. Your help is very much appreciated !!! 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