UDX Posted July 2, 2007 Posted July 2, 2007 Ok, coding and scripting is something I simply do not understand that easily so I do apologize for asking a possibly a stupid question. Let's suppose I have some text in file; first second fourth What I want to do is simply insert "third" after second in the next row. So trying to use replaceStringInFile I want my script to replace "second" with "second & CRLF third" but that's just not working. Should I use a different method if needed or is my syntax just way wrong (I mean i also tried $replace = "second" & @CRLF "third" but that wouldn't work also. Is this just possible; to replace a string with two row strings? I simply am using the sample file provided with AutoItv3 Help File. Also from being previously on java forums is there a necessity to insert code in the tags and where can I find that button when posting a new message?
Kogmedia Posted July 2, 2007 Posted July 2, 2007 (edited) Try this $file = "one"&@crlf&"two"&"four" $file = StringReplace($file,"two","two"&@CRLF&"three"&@crlf) MsgBox(0,"Ans",$file) Welcome to the Forum Edited July 2, 2007 by Kogmedia [font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
enaiman Posted July 2, 2007 Posted July 2, 2007 Here is an example based somehow on how _ReplaceStringInFile works (using a temporary file) #include <file.au3> Dim $arr _FileReadToArray("c:\ttt.txt", $arr) $tmp_file = FileOpen("c:\ttttmp.txt", 2) For $i=1 to UBound($arr)-1 FileWriteLine($tmp_file, $arr[$i]) If $arr[$i] = "two" Then FileWriteLine($tmp_file, "three") EndIf Next FileClose($tmp_file) FileCopy("c:\ttttmp.txt", "c:\ttt.txt", 1) FileDelete("c:\ttttmp.txt") It doesn't look too good and I'm sure others can find more "elegant" ways to do it ... but This is what I can do SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
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