jerem488 Posted November 4, 2008 Share Posted November 4, 2008 Hello, I would like delete blank lines of files. Only 5 last lines I used filecountlines. And then _FileWriteToLine but the function create a new blank line... I thinked to the function stringstripws, but i haven't find how to. thanks Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
November Posted November 4, 2008 Share Posted November 4, 2008 Hello, I would like delete blank lines of files. Only 5 last lines I used filecountlines. And then _FileWriteToLine but the function create a new blank line... I thinked to the function stringstripws, but i haven't find how to. thanksHi there m8, try this, removes ALL blanks: #include <array.au3> _FileReadToArray($host,$aRecords);*** (filename, array) _arraydisplay($aRecords, "Array with blanks");Display array while 1 $newvar = _ArraySearch($aRecords, "", 0, 0, 0, false); Search for null lines if @error = 6 Then; no more matches found ExitLoop Else _ArrayDelete($aRecords, $newvar);Delete current full line EndIf wend _arraydisplay($aRecords, "Array without blanks");Display array Enjoy Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
bogQ Posted November 4, 2008 Share Posted November 4, 2008 (edited) Hello, I would like delete blank lines of files. Only 5 last lines I used filecountlines. And then _FileWriteToLine but the function create a new blank line... I thinked to the function stringstripws, but i haven't find how to. thanks#include <File.au3> ;DELITE LINES must b 54321 not 12345 _FileWriteToLine(@ScriptDir&"\test.txt", 5, "", 1) _FileWriteToLine(@ScriptDir&"\test.txt", 4, "", 1) _FileWriteToLine(@ScriptDir&"\test.txt", 3, "", 1) _FileWriteToLine(@ScriptDir&"\test.txt", 2, "", 1) _FileWriteToLine(@ScriptDir&"\test.txt", 1, "", 1) every time you delete first line and try to delite secont problem is that second line is first becose you deleted firstone so itl skip one line basicly :/ but if you start from end line and move to the begining itl work Edited November 4, 2008 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
jerem488 Posted November 4, 2008 Author Share Posted November 4, 2008 Me, i would like delete 5 Last lines... Thnaks you and thanks in advance. In my opinion it is simply but for me, not always... Tuesday, it's rather difficult Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
jerem488 Posted November 4, 2008 Author Share Posted November 4, 2008 (edited) It's good. I am find it. So for delete "n" firsts lines we can do : For $i = n To 1 Step -1 _FileWriteToLine(@ScriptDir&"\Test.txt", $i, "", 1) NextoÝ÷ Ù©Ý~ÝzWz«¨¶z®¢ÙZ²Û%w¬ÁçÚºÚ"µÍÜ ÌÍÚHHHÈ ÌÍÐÛÛSYÛÈHÑ[PÛÝ[[ÊØÜ [È ][ÝÉÌLÕÝ ][ÝÊBÑ[UÜ]UÓ[JØÜ[É][ÝÉÌLÕÝ ][ÝË ÌÍÐÛÛSYÛË ][ÝÉ][ÝËJB^ Thanks Edited November 4, 2008 by jerem488 Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
rasim Posted November 4, 2008 Share Posted November 4, 2008 jerem488Another, fast way:$file = @ScriptDir & "\test.txt" $sRead = FileRead($file) $aString = StringSplit(StringStripCR($sRead), @LF) $ResultString = "" $count = 0 For $i = $aString[0] To 1 Step -1 If $aString[$i] = "" Then $count += 1 If $count <= 5 Then ContinueLoop EndIf $ResultString = $aString[$i] & @CRLF & $ResultString Next $hFile = FileOpen($file, 2) FileWrite($hFile, $ResultString) FileClose($hFile) 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