Ashalshaikh Posted July 20, 2009 Share Posted July 20, 2009 (edited) Hi First :: I'am Sorry :: My English Is Bad I made a very simple functions To control the lines of files This Is :: expandcollapse popup#Cs --------------------------------------- ;~ ################################ ;~ ########### Examples ########### ;~ ################################ #InClude "Array.au3" ; For Examples FileDelete ("Example.txt") ;--------- _StringInLine -------------- FileWriteLine ("Example.txt","Ashalshaikh (1)") FileWriteLine ("Example.txt","Ashalshaikh (2)") FileWriteLine ("Example.txt","Autoit (3)") FileWriteLine ("Example.txt","Ashalshaikh (4)") FileWriteLine ("Example.txt","Autoit (5)") FileWriteLine ("Example.txt","Ashalshaikh (6)") $E = _StringInLine ("Example.txt","Ashalshaikh") _ArrayDisplay ($E) FileDelete ("Example.txt") ;--------- _FileDownLine ----------- FileWriteLine ("Example.txt","Ashalshaikh (1)") FileWriteLine ("Example.txt","Ashalshaikh (2)") FileWriteLine ("Example.txt","Ashalshaikh (3)") FileWriteLine ("Example.txt","Ashalshaikh (4)") FileWriteLine ("Example.txt","Ashalshaikh (5)") FileWriteLine ("Example.txt","Ashalshaikh (6)") MsgBox (0,"Before",FileRead ("Example.txt")) _FileDownLine ("Example.txt","Ashalshaikh (3)") MsgBox (0,"After",FileRead ("Example.txt")) FileDelete ("Example.txt") ;--------- _FileUpLine ----------- FileWriteLine ("Example.txt","Ashalshaikh (1)") FileWriteLine ("Example.txt","Ashalshaikh (2)") FileWriteLine ("Example.txt","Ashalshaikh (3)") FileWriteLine ("Example.txt","Ashalshaikh (4)") FileWriteLine ("Example.txt","Ashalshaikh (5)") FileWriteLine ("Example.txt","Ashalshaikh (6)") MsgBox (0,"Before",FileRead ("Example.txt")) _FileUpLine ("Example.txt","Ashalshaikh (3)") MsgBox (0,"After",FileRead ("Example.txt")) FileDelete ("Example.txt") #Ce --------------------------------------- #Include <File.au3> ; #FUNCTION# ==================================================================================================================== ; Name...........: _StringInLine ; Description ...: Find Some String In File Lines And Return Lines Nuber In Array ; Syntax.........: _StringInLine (FilePath,String,[CompreType]) ; Parameters ....: FilePath - Path Of File. ; String - String ; CompreType - 0 => Find If String In Line (StringInStr) :: 1=> Find If String=Line ; Return values .: Success - Lines Numbers In Array ; Failure - First Row In Array = 0 ; Author ........: Ashalshaikh : Ahmad Alshaikh ; Example .......; No ; =============================================================================================================================== Func _StringInLine ($FilePath,$String,$CompreType = 0) Local $ReSult = "",$swd = "" If $CompreType <> 0 And $CompreType <> 1 Then $CompreType = 0 $LineNum = _FileCountLines ($FilePath) For $i = 1 To $LineNum Step 1 $Read = FileReadLine ($FilePath , $i) If $CompreType = 1 Then IF $Read = $String Then $ReSult &= $swd & $i $swd = "|" EndIf Else IF StringInStr($Read,$String)Then $ReSult &= $swd & $i $swd = "|" EndIf EndIf Next If Not $Read = $String Then Return 0 If $ReSult = "" Then Return StringSplit ($ReSult,"") Else Return StringSplit ($ReSult,"|") EndIf EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _FileDownLine ; Description ...: Down Line In File ; Syntax.........: _FileDownLine (FilePath,FullTextOnLine) ; Parameters ....: FilePath - Path Of File. ; FullTextOnLine - Text In That Line ; Return values .: Success - Return 1 ; Failure - Return 0 ; Remarks .......: Must FullTextOnLine=Line completely ; Author ........: Ashalshaikh : Ahmad Alshaikh ; Example .......; No ; =============================================================================================================================== Func _FileDownLine ($File,$FullTextOnLine) $LineNum = _StringInLine ($File,$FullTextOnLine,1) If $LineNum = 0 Then Return 0 Else For $x = 1 To $LineNum[0] $OrLineRead = FileReadLine ($File,$LineNum[$x]) If @error = 1 Then Return 0 Else $DownLineRead = FileReadLine ($File,$LineNum[$x] + 1) If @error = 1 Then Return 0 Else _FileWriteToLine($File, $LineNum[$x], $DownLineRead,1) If @error <> 0 Then Return 0 Else _FileWriteToLine($File, $LineNum[$x] + 1 , $OrLineRead,1) If @error <> 0 Then Return 0 Else Return 1 EndIf EndIf EndIf EndIf Next EndIf EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _FileUpLine ; Description ...: Up Line In File ; Syntax.........: _FileUpLine (FilePath,FullTextOnLine) ; Parameters ....: FilePath - Path Of File. ; FullTextOnLine - Text In That Line ; Return values .: Success - Return 1 ; Failure - Return 0 ; Remarks .......: Must FullTextOnLine=Line completely ; Author ........: Ashalshaikh : Ahmad Alshaikh ; Example .......; No ; =============================================================================================================================== Func _FileUpLine ($File,$FullTextOnLine) $LineNum = _StringInLine ($File,$FullTextOnLine,1) If $LineNum = 0 Then Return 0 Else For $x = 1 To $LineNum[0] $OrLineRead = FileReadLine ($File,$LineNum[$x]) If @error = 1 Then Return 0 Else $DownLineRead = FileReadLine ($File,$LineNum[$x] - 1) If @error = 1 Then Return 0 Else _FileWriteToLine($File, $LineNum[$x], $DownLineRead,1) If @error <> 0 Then Return 0 Else _FileWriteToLine($File, $LineNum[$x]- 1 , $OrLineRead,1) If @error <> 0 Then Return 0 Else Return 1 EndIf EndIf EndIf EndIf Next EndIf EndFunc If there are errors, I am sorry I Wait For Your Comments Thank You !! Edited July 22, 2009 by Ashalshaikh Link to comment Share on other sites More sharing options...
logmein Posted July 22, 2009 Share Posted July 22, 2009 CoOl, it's useful for me [font=arial, helvetica, sans-serif][s]Total USB Security 3.0 Beta[/s] | [s]Malware Kill[/s] | Malware Scanner | Screen Hider | Locker | Matrix Generator[s]AUTO-SYNC 1.0 | MD5 Hash Generator | URL Checker | Tube Take [/s]| Random Text[/font] 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