Raestlin Posted April 20, 2006 Share Posted April 20, 2006 I have code that assigns a DOS output like: Process Status Time Printer Balance User Address 2716 ACTIVE 15:41:35 0 0 chaney 172.17.100.198 3824 ACTIVE 15:42:27 0 1 administrator 172.17.100.198 *** 2 session(s) ***to a string variable. How can I then parse that string of all the above to grab the 2nd and 3rd line and assign each piece (delimited by space or tab) to an array variable? So, in other words, I would like the full string above to be processed into: $line2[0] = 7, which is the number of pieces in line 2. $line2[1] = "2716" $line2[2] = "ACTIVE" $line2[3] = "15:41:35" ... $line2[7] = "172.17.100.198" $line3[0] = 7, which is the number of pieces in line 3. $line3[1] = "3824" $line3[2] = "ACTIVE" $line3[3] = "15:42:27" ... $line2[7] = "172.17.100.198" Link to comment Share on other sites More sharing options...
Uten Posted April 20, 2006 Share Posted April 20, 2006 Didn't your installation come with the help file? Take a look at the String management section. StringSplit and StringRegExp comes to mind Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
neogia Posted April 20, 2006 Share Posted April 20, 2006 This should work: #include <Array.au3> $str = ClipGet() $ret = StringSplit($str, @CRLF) If IsArray($ret) Then For $line In $ret If $line <> "" Then $ret2 = StringSplit($line, " ") _ArrayDisplay($ret2, "") EndIf Next EndIf [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia Link to comment Share on other sites More sharing options...
Raestlin Posted April 24, 2006 Author Share Posted April 24, 2006 This should work: #include <Array.au3> $str = ClipGet() $ret = StringSplit($str, @CRLF) If IsArray($ret) Then For $line In $ret If $line <> "" Then $ret2 = StringSplit($line, " ") _ArrayDisplay($ret2, "") EndIf Next EndIf Thanks Neogia, that code helped me figure out my code perfectly. 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