pollop Posted January 12, 2010 Posted January 12, 2010 (edited) Hi I'm trying to get some informations from a text but i have some problems doing it :/ Here's is the string contained in a variable : 10:59 / 41:37 Frame-rate 24.89 (1X) Sync Offset avg: 0 ms, dev: 5 ms Frames drawn: 384, dropped: 1 Jitter 3 ms Buffers [0]: 1153/4267 KB [1]: 1895/854 KB (p0) Bitrate [0]: 600/348 Kb/s [1]: 159/153 Kb/s (avg/cur) Shader Editor Shader Editor Delete Subresync Playlist Playlist Capture Settings Capture Settings ... What i'm trying to do is to extract the "10:59" and "41:37" into two variables... ( If the runtime is more than an hour, it's in three parts : "01:25:11") How can i extract the text until the carriage return ? Thanks. Pollop PS : Sry for my poor english, i'm doing my best Edited January 12, 2010 by pollop
Zedna Posted January 12, 2010 Posted January 12, 2010 $text = "10:59 / 41:37" & @CRLF & "Frame-rate" $lines = StringSplit($text, @CRLF, 1) $line1 = $lines[1] $vars = StringSplit($line1, " / ", 1) MsgBox(0,'Result', "variable 1: " & $vars[1] & @CRLF & "variable 2: " & $vars[2]) Resources UDF ResourcesEx UDF AutoIt Forum Search
pollop Posted January 12, 2010 Author Posted January 12, 2010 $text = "10:59 / 41:37" & @CRLF & "Frame-rate" $lines = StringSplit($text, @CRLF, 1) $line1 = $lines[1] $vars = StringSplit($line1, " / ", 1) MsgBox(0,'Result', "variable 1: " & $vars[1] & @CRLF & "variable 2: " & $vars[2]) Thanks a lot for your help ! How can i be sure that it's a @CRLF and not a @LF ou @CR :/ Will there be a problem if i use @CRLF and if it's a @LF ? Thanks
Zedna Posted January 12, 2010 Posted January 12, 2010 How can i be sure that it's a @CRLF and not a @LF ou @CR :/ Will there be a problem if i use @CRLF and if it's a @LF ? It's easy :-) $text = "10:59 / 41:37" & @CRLF & "Frame-rate" $text = StringReplace($text, @CRLF, @LF) $text = StringReplace($text, @CR, @LF) $lines = StringSplit($text, @LF, 1) $line1 = $lines[1] $vars = StringSplit($line1, " / ", 1) MsgBox(0,'Result', "variable 1: " & $vars[1] & @CRLF & "variable 2: " & $vars[2]) Resources UDF ResourcesEx UDF AutoIt Forum Search
Mison Posted January 13, 2010 Posted January 13, 2010 (edited) Will there be a problem if i use @CRLF and if it's a @LF ? I don't think there will be a problem. #include <array.au3> ; for _ArrayDisplay $text = "line 1" & @CRLF & "line 2" & @CR & "line 3" & @LF & "line 4" $lines = StringSplit($text, @CRLF) _ArrayDisplay($lines) Edited January 13, 2010 by Mison Hi ;)
Zedna Posted January 13, 2010 Posted January 13, 2010 I don't think there will be a problem. #include <array.au3> ; for _ArrayDisplay $text = "line 1" & @CRLF & "line 2" & @CR & "line 3" & @LF & "line 4" $lines = StringSplit($text, @CRLF) _ArrayDisplay($lines) This is wrong. It doesn't work correctly. Resources UDF ResourcesEx UDF AutoIt Forum Search
Mison Posted January 14, 2010 Posted January 14, 2010 This is wrong. It doesn't work correctly. Is it? Why is that? It does return an empty line, but that can be eliminated by adding this line: If $lines[$i] = "" Then ContinueLoop I'm not questioning your solution, just keen to know why. Hi ;)
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