Xenobiologist Posted March 7, 2006 Share Posted March 7, 2006 HI, I´m trying to read a gbx file from my brother and get the besttime out of it. But I can´t read the file with : __FileReadToArray, FileRead or FileReadLine succesfully. If I look into the file with UltraEdit, the best-time is written clearly. How can I read it? Any ideas? Thanks! So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 7, 2006 Moderators Share Posted March 7, 2006 HI,I´m trying to read a gbx file from my brother and get the besttime out of it. But I can´t read the file with :__FileReadToArray, FileRead or FileReadLine succesfully.If I look into the file with UltraEdit, the best-time is written clearly.How can I read it?Any ideas?Thanks!So long,MegaWorks for me when I use FileMove() and rename it with a .txt extension 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...
Xenobiologist Posted March 7, 2006 Author Share Posted March 7, 2006 Works for me when I use FileMove() and rename it with a .txt extension Hmmh, then I can read the txt file, but I still couldn´t find the string best in it. Something like: #include <file.au3> FileCopy(@ScriptDir & "\Matze_A-9.Replay.gbx", @ScriptDir & "\Matze_A-9.Replay_TM.txt", 0) $file = FileOpen(@ScriptDir & "\Matze_A-9.Replay_TM.txt", 0) $test = FileOpen(@ScriptDir &"\new.txt", 2) $count = 1 While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop If StringInStr($line, "best", 0, 1) <> 0 Then MsgBox(0,$count, $line) EndIf $count += 1 Wend FileClose($file) FileClose($test) won´t work. Any ides? Thanks! So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 7, 2006 Moderators Share Posted March 7, 2006 Hmmm, I had to save the txt file under all files to find best="6600" 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...
poisonkiller Posted March 7, 2006 Share Posted March 7, 2006 Try this: FileCopy("Matze_A-9.Replay.gbx", "Matze_A-9.Replay.txt") If @error Then Exit $times = _StringBetween(FileRead("Matze_A-9.Replay.txt", FileGetSize("Matze_A-9.Replay.txt")), 'times best="', '" respawns') MsgBox(0, "", $times) Func _StringBetween($s,$from,$to) $x=StringInStr($s,$from)+StringLen($from) $y=StringInStr(StringTrimLeft($s,$x),$to) Return StringMid($s,$x,$y) EndFunc Worked on me. Link to comment Share on other sites More sharing options...
w0uter Posted March 7, 2006 Share Posted March 7, 2006 its a binary file and has null's in it thus you need to use binarystring $as_file = StringRegExp(StringTrimLeft(String(BinaryString(chr(0) & FileRead('Matze_A-9.Replay.gbx'))), 4), '(..)*', 3) $s_txt = '' for $i = 0 to UBound($as_file)-1 $as_file[$i] = int('0x' & $as_file[$i]) If $as_file[$i] > 0x1F AND $as_file[$i] < 0x7F Then $s_txt &= chr($as_file[$i]) Next MsgBox(0, 'This is for you to parse', $s_txt) My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Xenobiologist Posted March 7, 2006 Author Share Posted March 7, 2006 Try this: FileCopy("Matze_A-9.Replay.gbx", "Matze_A-9.Replay.txt") If @error Then Exit $times = _StringBetween(FileRead("Matze_A-9.Replay.txt", FileGetSize("Matze_A-9.Replay.txt")), 'times best="', '" respawns') MsgBox(0, "", $times) Func _StringBetween($s,$from,$to) $x=StringInStr($s,$from)+StringLen($from) $y=StringInStr(StringTrimLeft($s,$x),$to) Return StringMid($s,$x,$y) EndFunc Worked on me. Hi poisonkiller & SmOke_N, thanks for helping me. That worked. So long, Mega P.S.: Now, I only have to figure out, why my first try didn´t work. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Xenobiologist Posted March 7, 2006 Author Share Posted March 7, 2006 (edited) its a binary file and has null's in it thus you need to use binarystring CODE $as_file = StringRegExp(StringTrimLeft(String(BinaryString(chr(0) & FileRead('Matze_A-9.Replay.gbx'))), 4), '(..)*', 3) $s_txt = '' for $i = 0 to UBound($as_file)-1 $as_file[$i]= int('0x' & $as_file[$i]) If $as_file[$i] > 0x1F AND $as_file[$i] < 0x7F Then $s_txt &= chr($as_file[$i]) Next MsgBox(0, 'This is for you to parse', $s_txt) Thanx w0uter, now I even have to understand what you are doing, too. :"> Hmmh 0x1F and 0x7F is Hex ... ok ok, give me some time and I figure it out. So long, Mega Edited March 7, 2006 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times 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