jesternaut Posted January 10, 2008 Share Posted January 10, 2008 Hello all, I need to read a multiline string into an array similar to _FileReadToArray but I can't fine a UDF, so I had to write the string to a file so I could use the _FileReadToArray. This seems sooooo ugly. The main reason I need to use the _FileReadToArray is so I can ignore the 1st 3 lines. Below is my code. CODE#include <GuiConstants.au3> #include <Constants.au3> #include <Date.au3> #include <File.au3> #include <Array.au3> wait4job2bdone() Func wait4job2bdone() ;wait for the restore job to complete Local $sDir = "C:\Program Files\CA\BrightStor ARCserve Backup" Local $sExe = "ca_qmgr -list" Local $sOutput = "" Local $PID = Run($sDir & "\" & $sExe, $sDir, @SW_MINIMIZE, $STDOUT_CHILD + $STDERR_CHILD) Do Sleep(20) If StdoutRead($PID, 0, 1) Then $sOutput &= StdoutRead($PID) If StderrRead($PID, 0, 1) Then $sOutput &= StderrRead($PID) Until Not ProcessExists($PID) Msgbox(0,'Output var: ', $sOutput) _FileWriteLog(@ScriptDir & "\jobinfo.log", $sOutput ) dim $ajobrecords If Not _FileReadToArray(@ScriptDir & "\jobinfo.log", $ajobrecords) Then ;$$ajobrecords is an array holding the results of ;ca_qmgr -list. MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf Msgbox(0,'number of Records: ', $ajobrecords[0]) For $x = 1 to $ajobrecords[0] Msgbox(0,'Record:' & $x, $ajobrecords[$x]) Next EndFunc Any suggestions????? Thanks Link to comment Share on other sites More sharing options...
Xenobiologist Posted January 10, 2008 Share Posted January 10, 2008 Hi, does StringSplit help? 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...
DW1 Posted January 10, 2008 Share Posted January 10, 2008 (edited) does StringSplit help?If so then try something like this: #include<array.au3> $string = "" $string &= "one line" & @CRLF $string &= "two lines" & @CRLF $string &= "three lines" & @CRLF $string &= "four lines" & @CRLF $string &= "five lines" & @CRLF $string &= "six lines" & @CRLF $string &= "seven lines" & @CRLF $string &= "eight lines" MsgBox( 0, "test", $string ) $array = StringSplit( $string, @CR ) For $temp = 1 To $array[0] If StringLeft( $array[$temp], 1 ) = @LF Then $array[$temp] = StringTrimLeft( $array[$temp], 1 ) Next _ArrayDisplay( $array, "test" ) EDIT: See GEOSoft's post below mine to omit the first 3 lines. Edited January 10, 2008 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
GEOSoft Posted January 10, 2008 Share Posted January 10, 2008 If so then try something like this: #include<array.au3> $string = "" $string &= "one line" & @CRLF $string &= "two lines" & @CRLF $string &= "three lines" & @CRLF $string &= "four lines" & @CRLF $string &= "five lines" & @CRLF $string &= "six lines" & @CRLF $string &= "seven lines" & @CRLF $string &= "eight lines" MsgBox( 0, "test", $string ) $array = StringSplit( $string, @CR ) For $temp = 1 To $array[0] If StringLeft( $array[$temp], 1 ) = @LF Then $array[$temp] = StringTrimLeft( $array[$temp], 1 ) Next _ArrayDisplay( $array, "test" )oÝ÷ Ûú®¢×z+r§æ(ºh¬±çmêZ®Ü!z·ã±¨¶$ayø«²Ýåw¬jëh×6#include<array.au3> $string = "" $string &= "one line" & @CRLF $string &= "two lines" & @CRLF $string &= "three lines" & @CRLF $string &= "four lines" & @CRLF $string &= "five lines" & @CRLF $string &= "six lines" & @CRLF $string &= "seven lines" & @CRLF $string &= "eight lines" MsgBox( 0, "test", $string ) $array = StringSplit( $string, @CR ) For $temp = 4 To $array[0] If StringLeft( $array[$temp], 1 ) = @LF Then $array[$temp] = StringTrimLeft( $array[$temp], 1 ) Next _ArrayDisplay( $array, "test" ) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
DW1 Posted January 10, 2008 Share Posted January 10, 2008 lol, oops. Thanks AutoIt3 Online Help 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