Jump to content

Question - How to delete a single line


caramen
 Share

Recommended Posts

6 minutes ago, careca said:

I would say it's obvious only the line is deleted, that's expected, now to pull the rest of the text a line up you have to resort to more code.

HelpFile saying : If _FileWriteToLine() is called with $bOverWrite as 1 and $sText as "", it will delete the line.

I am sorry mate but no, not really obvius xD 

 

And still the wanted result is after @error 7 So ... 

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

22 minutes ago, caramen said:

HelpFile saying : If _FileWriteToLine() is called with $bOverWrite as 1 and $sText as "", it will delete the line.

And it does. And that's all it does, the rest of the text stays where it is.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

2 minutes ago, careca said:

And it does. And that's all it does, the rest of the text stays where it is.

I am sorry but no for me there is a difference between erase the line and erase the string. The line is still here

8 minutes ago, JLogan3o13 said:

@caramen why did you report yourself?? :blink:

For bug report :lol:

 

Anyway. What is the way for me to erase one line. 

FileRead

StringReplace and

FileWrite ?

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

#include <File.au3>
Local $sFileRead, $Txt
Local Const $sFilePath = @ScriptDir&"\xxx.txt"
_FileWriteToLine ( $sFilePath , 3 , "" , True , True )
Local $FO = FileOpen($sFilePath)
$Count = _FileCountLines($sFilePath)
For $l = 1 To $Count
$sFileRead = FileReadLine($FO, $l)
If $sFileRead <> '' Then
    $Txt &= $sFileRead & @crlf
EndIf
Next
FileClose($FO)
MsgBox(64 + 262144, '$Txt', $Txt)

Just do whatever with the result $txt, can open and write to a new file or overwrite the same file.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • Moderators
8 minutes ago, caramen said:

For bug report :lol:

Constantly seem to be asking you to engage the gray matter before you post...

If you think there is a bug, you can use that great big Bug Tracker button at the top of the forum

1.png.ee928f23d8f90573ba34aef832dd4259.png

But as it sounds throughout this thread like you simply are not comprehending how the function works, don't be shocked if the reply is brief.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

How about FileReadToArray, then _ArrayDelete the line you want to delete, then _FileWriteFromArray to rewrite the file without the line?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

caramen,

I see the problem with _FileWriteToLine - and I remember why it happens.

There was considerable discussion when the function was rewritten some years ago as to whether this "delete a line" functionality should be retained as it removes the possibility of replacing an existing line with a blank one. If it were retained, the only option to "overwrite" with a blank line was to remove the line completely and then rewrite a new blank one, which required 2 calls to the function. The consensus as I recall was that overwriting a line with a blank was more likely than deleting a line - and so the code was amended, but not the Help file.

So the question resurfaces - which of the 2 functionalities is more useful? Or should both be available - as in this suggestion for a new version of the function:

#include <File.au3>
#include <MsgBoxConstants.au3>

; These constants added to FileConstants.au3
Const $FWTL_INSERT = 0
Const $FWTL_OVERWRITE = 1
Const $FWTL_DELETE = 2

$sFile = @ScriptDir & "\test.txt"
$sContent = "1" & @CRLF & "2" & @CRLF & "3" & @CRLF & "4"

FileDelete($sFile)
FileWrite($sFile, $sContent)
; Insert a line
$iRet = _FileWriteToLine_Mod($sFile, 3, "fred", $FWTL_INSERT)
ConsoleWrite($iRet & " - " & @error & @CRLF)

FileDelete($sFile)
FileWrite($sFile, $sContent)
; Overwrite a line
$iRet = _FileWriteToLine_Mod($sFile, 3, "fred", $FWTL_OVERWRITE)
ConsoleWrite($iRet & " - " & @error & @CRLF)

FileDelete($sFile)
FileWrite($sFile, $sContent)
; Delete a line - obviously the $sText parameter is ignored
$iRet = _FileWriteToLine_Mod($sFile, 3, "fred", $FWTL_DELETE)
ConsoleWrite($iRet & " - " & @error & @CRLF)

FileDelete($sFile)

; Use 3 mode options - insert, overwrite, delete
Func _FileWriteToLine_Mod($sFilePath, $iLine, $sText, $iMode = $FWTL_INSERT, $bFill = False)
    If $iMode = Default Then $iMode = $FWTL_INSERT
    If $bFill = Default Then $bFill = False
    If Not FileExists($sFilePath) Then Return SetError(2, 0, 0)
    If $iLine <= 0 Then Return SetError(4, 0, 0)
    If $iMode < 0 Or $iMode > 2 Then Return SetError(5, 0, 0)
    If Not IsString($sText) Then
        $sText = String($sText)
        If $sText = "" Then Return SetError(6, 0, 0)
    EndIf
    If Not IsBool($bFill) Then Return SetError(7, 0, 0)
    ; Read current file into array
    Local $aArray = FileReadToArray($sFilePath)

    ; Create empty array if empty file
    If @error Then Local $aArray[0]
    Local $iUBound = UBound($aArray) - 1
    ; If Fill option set
    If $bFill Then
        ; If required resize array to allow line to be written
        If $iUBound < $iLine Then
            ReDim $aArray[$iLine]
            $iUBound = $iLine - 1
        EndIf
    Else
        If ($iUBound + 1) < $iLine Then Return SetError(1, 0, 0)
    EndIf

    Switch $iMode
        Case 0 ; Insert
            $aArray[$iLine - 1] = $sText & @CRLF & $aArray[$iLine - 1]
        Case 1 ; Overwrite
            $aArray[$iLine - 1] = $sText
        Case 2 ; Delete
            _ArrayDelete($aArray, $iLine - 1)
            $iUBound -= 1
    EndSwitch

    ; Concatenate array elements
    Local $sData = ""
    For $i = 0 To $iUBound
        $sData &= $aArray[$i] & @CRLF
    Next
    $sData = StringTrimRight($sData, StringLen(@CRLF)) ; Required to strip trailing EOL

    ; Just for illustration purposes
    MsgBox($MB_SYSTEMMODAL, $iMode, $sData)

    ; Write data to file
    Local $hFileOpen = FileOpen($sFilePath, FileGetEncoding($sFilePath) + $FO_OVERWRITE)
    If $hFileOpen = -1 Then Return SetError(3, 0, 0)
    FileWrite($hFileOpen, $sData)
    FileClose($hFileOpen)
    Return 1
EndFunc   ;==>_FileWriteToLine

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@Melba23 Thanks for that answer i feel like finaly less stupid. 

I will study before posting to give a constructive answer.

@mikell :sweating: The purpose is to delete a line :P Not save it xD

Btw what would you do to replace a Cells named with a randge of C3 to J400 To transforme any of the cell into B2 I would like to dodge the fact of coding the 3200 cells :D

Actually i replace any letter into B Then after i will replace any number by 2

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

14 hours ago, Melba23 said:

which required 2 calls to the function.

@Melba23 I am asking becose i dont know ver good what is the impact of calling a function 2 time on AutoIT:

-1) Exept maybe a more longer render ?

2) If it is the case it will be only if we erase the line ? Or For each variant of the macro ?

3) what whould be the impact ? 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

  • Moderators

caramen,

No real impact - other than being a nuisance.

- With the old functionality you would only need the 2 calls when you wanted to delete the content of a line: one call to delete the existing line and another to insert a new blank line.

- With the new functionality you would have to use a wrapper function using  FileReadToArray, _ArrayDelete, FileWriteToArray (or some form of FileOpen, SFileRead, StringRegExpReplace, FileWrite, FileClose magic) to completely delete a line.

So IMO getting both functionalities into the _FileWriteToLine function is a "good thing".

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

12 minutes ago, Melba23 said:

So IMO getting both functionalities into the _FileWriteToLine function is a "good thing".

I fall into that opinion too. 

Why not then... I understand why it was reacting like that then

 

On 21/11/2018 at 1:12 PM, caramen said:

This make it work. If i erase everything 3 time it is now working fine. I guess it is becose it is first erasing text and replace by blank and then the second time replace the blank area by nothing and deleting the cariage return i dotn know...

 

Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
;~                            $File2 = FileOpen ( @ScriptDir&"\Log.txt",  $FO_APPEND )
;~                            $File02 = FileOpen ( @ScriptDir&"\Data\Log02.txt",  $FO_APPEND )
;~                            $File002 = FileOpen ( @ScriptDir&"\Data\Log002.txt",  $FO_APPEND )
                    _GUICtrlListView_DeleteItem($Console, DllStructGetData($tInfo, "Index"))
                    _FileWriteToLine ( @ScriptDir&"\Log.txt" , DllStructGetData($tInfo, "Index") , "" , True , True )
                    _FileWriteToLine ( @ScriptDir&"\Data\Log02.txt" , DllStructGetData($tInfo, "Index") , "" , True , True )
                    _FileWriteToLine ( @ScriptDir&"\Data\Log002.txt" , DllStructGetData($tInfo, "Index") , "" , True , True )
                    _FileWriteToLine ( @ScriptDir&"\Log.txt" , DllStructGetData($tInfo, "Index") , "" , True , True )
                    _FileWriteToLine ( @ScriptDir&"\Data\Log02.txt" , DllStructGetData($tInfo, "Index") , "" , True , True )
                    _FileWriteToLine ( @ScriptDir&"\Data\Log002.txt" , DllStructGetData($tInfo, "Index") , "" , True , True )
                    _FileWriteToLine ( @ScriptDir&"\Log.txt" , DllStructGetData($tInfo, "Index") , "" , True , True )
                    _FileWriteToLine ( @ScriptDir&"\Data\Log02.txt" , DllStructGetData($tInfo, "Index") , "" , True , True )
                    _FileWriteToLine ( @ScriptDir&"\Data\Log002.txt" , DllStructGetData($tInfo, "Index") , "" , True , True )

Seem like the macro is still getting like in the old code. 

Dont realy know why.. But just so you know. 

 

So yes I vote for both functionnality.

Anyway i dont know if modify the helpfile involve lot of work. i guess not. But it should be rewrited until there. 

 

Best thing to keep all functionnality... 

If String is String then delete 

If string is "" Then delete line. or why delete a blank line. That seem like logical way to do that.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

3 hours ago, caramen said:

The purpose is to delete a line :P Not save it xD

Hmm did you even try to run the script ?  :blink:

FileDelete("xxx.txt")
$text = "line_1" &@crlf& "line_2" &@crlf& "line_3" &@crlf& "line_4" &@crlf& "line_5" &@crlf
FileWrite("xxx.txt", $text)
Msgbox(0,"before", $text)

;==============

$s = _DeleteLine("xxx.txt", 3)  ; delete line 3
Msgbox(0,"after", $s)

Func _DeleteLine($file, $n)
   $txt = FileRead($file)
   Return StringRegExpReplace($txt, '(?ms)((^\N*\R?){' & $n-1 & '})(?2)?(.*\z)', "$1$3")
EndFunc

 

Link to comment
Share on other sites

Not yet but i readed you at least ^^ (this script is at home now.)

16 hours ago, mikell said:

For the fun  :)
If $n = 0 or $n > nb of lines in the file, no line is deleted

That suprised me so i even used G.Translate to be sure. 

 

Maybe it was "noW" ?

 

Anyway i got it now sry yes no problem :) You 're so pro with that RegExp :P 

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

2 hours ago, mikell said:

Func _DeleteLine($file, $n)    $txt = FileRead($file)    Return StringRegExpReplace($txt, '(?ms)((^\N*\R?){' & $n-1 & '})(?2)?(.*\z)', "$1$3") EndFunc

@mikell can i put that in the snipet topic ? I will of course add crédit to you

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

21 hours ago, Melba23 said:

So the question resurfaces - which of the 2 functionalities is more useful? Or should both be available

I believe it could be as simple as having a flag to determine the behaviour, mas many other functions do. And maybe rename the function to something else, or leave this one and just add another, one overwrites, the other deletes.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • Moderators

careca,

Quote

it could be as simple as having a flag to determine the behaviour

Have you looked at my code for a suggested new function in the same post as the line you quoted? Obviously not, as that is exactly what it does.....

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

On 22/11/2018 at 8:22 PM, Melba23 said:

Or should both be available

I didn't read the looong discussion but couldn't this be done by using the $bFill parameter : "setting the $bFill parameter to True will force it will add blank lines"
So :
$bOverWrite = True, $bFill = False  => delete the line
$bOverWrite = True, $bFill = True  =>  write a blank line
?

Anyway such a feature should make everybody agree - and finally close the discussion  :)

 

 

Link to comment
Share on other sites

Just read this long thread, now I got a headache :blink:

1) @caramen : when you got this "error 7", here is a way to find the reason :
Edit the include file "File.au3" to see what's inside Func _FileWriteToLine(), you'll find this line :

If Not IsBool($bFill) Then Return SetError(7, 0, 0)

Now you know why you go the error 7 : each time you called the function with $bFill = 1 (instead of True), then @error was set to 7

2) By the way, something a bit strange in the function is this line :
If Not (IsBool($bOverWrite) Or $bOverWrite = 0 Or $bOverWrite = 1) Then Return SetError(5, 0, 0)

So why accepting a 0 or 1 for $bOverWrite (which is boolean too) then refusing it for $bFill ?
I'd prefer the same behavior, accepting True (or False) for both of them, no other choice.
Maybe Melba23 will explain us, in case there is a special reason ?

3) As we're talking a lot in this thread of deleting/erasing, it brings @CRLF in bright light, so something isn't really clear for me with this function _FileWriteToLine(), please have a look at these 2 pics :

xxx.jpg.c32c85ac7dafdf4e6b3bdc63f25e5a13.jpg

yyy.jpg.a7497e3d102829c6eaaf5b5f078e5e04.jpg

Both files (xxx.txt and yyy.txt) got 3 same lines AAA BBB CCC, with a @CRLF (0D+0A) between line 1 and line 2, then another @CRLF between line 2 and line 3. Now the files differ : 1st file xxx.txt doesn't end with a @CRLF, 2nd file yyy.txt ends with a @CRLF

My question is : why both files are treated equally when you apply to them the same treatment :
_FileWriteToLine ($sFilePath ,3 ,"DDD" ,True) ; this will overwrite 3rd line "CCC" with "DDD"

zzz.jpg.bf8129466846662ac4ee68fbb03d2e7c.jpg

Both files will now look exactly the same (zzz.txt above), without the last @CRLF because of this line in the function :
$sData = StringTrimRight($sData, StringLen(@CRLF)) ; Required to strip trailing EOL

imho, you can't treat them both the same way : if there was a @CRLF after the last line and the last line is treated by the function as described, then the last @CRLF should stay as it was before the function was called. Some applications will get issues if the last @CRLF vanished in the air.

Gee, now this thread is even longer :sweating:

Link to comment
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...