iiyama Posted February 22, 2010 Share Posted February 22, 2010 Hi, I'm hoping that someone could give me a few tips on a problem I have regarding Arrays. What I'm wanting to do is load a txt file into an Array then search for some text and find the line number of said text. I then need to add an extra 1 to the line number it finds. So if it finds 5 then = 6, 11 = 12 and so on. I guess I would then be able to use the variable containg the "line number" to then copy a line from one text file into another. Example would be [Test1] 1=jshdjsjsj 2=jshsjdjdhsjdh [TESTa] <<<< find line number then add 1 to then put the 1=jsjshdfawe "line number" into a variable. 1=jsjshdfawe 2=363632 *** I would rather be able to copy 1=jsjshdfawe into a variable and not worry about adding a 1 to a number. Otherwise if it were possible then just be able to copy 1=jsjshdfawe into a variable instead for [Testa]. I can normaly work out how to do things but Arrays do confuse me a bit. I have attached what I have played with so far but can't think how to proceed. I have searched the forums but not been able to work out how to be able to do it. I hope someoneone would be be able to help me. I have only been able to capture the line of the search string. #include <Array.au3> #include <file.au3> Dim $aRecords _FileReadToArray("c:\in\test.txt",$aRecords) $sSearch = "[TESTa]" ;<== search text $iIndex = _ArraySearch($aRecords, $sSearch, 0, 0, 0, 1) If @error Then If $iIndex = -1 Then Exit EndIf Else MsgBox(0, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & ".") _FileWriteToLine("c:\in\NEWfile.txt", 1, '11 = ' & $iIndex, 1) EndIf Link to comment Share on other sites More sharing options...
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 account
Already have an account? Sign in here.Sign In Now