kaibraine Posted October 17, 2006 Share Posted October 17, 2006 I have a poker programme I use quite alot. I am trying to write a script that reads info from poker hand history .txt files and input them into a programme for analysis. I have no problem getting autoit to recognise constant variables and associate these with certain mouse gestures ( I can't get the control I.D's so Im using MouseMove, MouseClick etc.) I can also get autoit to open all files in a directory one at a time for processing. The trouble I am having is that I can't figure out how to get autoit to retrieve specific card values from the .txt files. For instance I want to instruct autoit to find the first example that says "dealt to *username*" then read the values i.e AcJd and return these as variables to use for inputing to the programme. I want to repeat this for "flop" "turn" then "river" The .txt files contain up to 100 hands in each file so I want to repeat the process for every hand in the file before moving onto the next file. I have no idea where to start, I've been trawling through the helpfiles and can't work it out. I don't want anyone to tell me what to script. Just where to start, what instructions I should experiment etc. I really want to learn more about this software, I wish there was some books out about it. Any help to get me on the right track with this woud be greatly appreciated. thanks Link to comment Share on other sites More sharing options...
Valuater Posted October 17, 2006 Share Posted October 17, 2006 maybe... #include <file.au3> Dim $aRecords, $textfile = "myfilename.txt" If Not _FileReadToArray($textfile,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] Msgbox(0,'Record:' & $x, $aRecords[$x]) Next 8) Link to comment Share on other sites More sharing options...
kaibraine Posted October 17, 2006 Author Share Posted October 17, 2006 Thx, looks like a good place to start. Experimenting now Link to comment Share on other sites More sharing options...
Valuater Posted October 17, 2006 Share Posted October 17, 2006 Welcome 8) Link to comment Share on other sites More sharing options...
kaibraine Posted October 17, 2006 Author Share Posted October 17, 2006 This helps kinda, but I still am gettinbg nowhere due to my scripting noobness. This returns each line of text in an array. So basically I can identify a particular line of text by a number, I got that part. How can I retrieve my card values from the array though? For example the first line that comes up in the array that I am interested in is "Record 18" in the array with the text "Dealt to xxxxx [ Th 8d]" It's the values in the [] that I am interested in. How could I get these to show in a MsgBox for example? If someone could help me with this then I'd probably manage from there. :"> Link to comment Share on other sites More sharing options...
Valuater Posted October 17, 2006 Share Posted October 17, 2006 define your search word/phrase $find = "Record 18" put this in the loop if StringInStr($aRecords[$x], $find) then MsgBox(0,0,0) 8) Link to comment Share on other sites More sharing options...
kaibraine Posted October 17, 2006 Author Share Posted October 17, 2006 Ok after lots of thinking to try and solve this I think I am beginning to understand. I can use StringInStr to search for a substring within a string, for example Ad (ace of diamonds) in the given string. If I find the occurence of this I can instruct autoit to send specific keystrokes to the programme I am using via a function. If it doesnt find it I can instruct autoit to search for the next card i.e 2d etc. through all 52 cards. Great. Is there no quicker way though? Also the cards need to be put in in order. i.e. Ad2c not 2cAd. Using this method autoit will find the card nearest the top of the script first right? I.e if i programmed it to look for Ad and if it din't find it to look for 2D then the commands to the 3rd party programme would be sent in the order Ad2d even if the actual cards were in the order 2dAd. If I had to programme autoit to look for 2 card combinations thats 1,320 different possible combinations for the holecards. For the Flop I don't have a clue but considering there are 3 cards it would be a nightmare to try and programme all the possible combinations of flops that could come. What I need is to be able to search the string for the value in a position rather than the position of a value I guess. Sorry for all the rambling but I find this stuff real difficult to explain in english lol. Link to comment Share on other sites More sharing options...
kaibraine Posted October 17, 2006 Author Share Posted October 17, 2006 Ok Strings!!!! I'm on it!!!!! Link to comment Share on other sites More sharing options...
kaibraine Posted October 17, 2006 Author Share Posted October 17, 2006 (edited) OK, StringMid can help me, but I have failed miserably. I hoped my variable $Hcards would be able to return the cards from $aRecords but all I get is an error saying subscript used with non-Array variable. How do I extract characters from an array? #include <file.au3> Dim $aRecords, $textfile = "test.txt", $find = "Dealt to xxxxxxxx", $Hcards = StringMid ($aRecords[$x], 23, 5) If Not _FileReadToArray($textfile,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] if StringInStr($aRecords[$x], $find) then MsgBox (0, "cards", $Hcards) EndIf Next Edited October 17, 2006 by kaibraine Link to comment Share on other sites More sharing options...
kaibraine Posted October 17, 2006 Author Share Posted October 17, 2006 YAY! Dim $file = FileOpen("test.txt", 0), $hcards1 = "Dealt to xxxxxx" ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) $hcards2 = StringMid ($line, 23, 6) If @error = -1 Then ExitLoop If StringInStr($line, $hcards1 ) then MsgBox(0, "cards", $hcards2) Wend FileClose($file) 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