hello Delusion,
you want delete multiple marked lines in text-file using Listview (?)
mark multiple lines (leftclick) and delete it with righclick
Code:
;------- create a test-file ----
F1=%A_scriptdir%\test55.txt
Gui,1:default
Gui,1:Font,S10 cDefault, Verdana
EF=`r
ifnotexist,%F1%
{
AA=
(
Line3A;3AA;3AAA;3AAAA%EF%
Line1A;1BB;1CCC;1DDDD%EF%
Line5A;5BB;5CCC;5DDDD%EF%
Line2A;2BB;2CCC;2DDDD%EF%
Line4A;4BB;4CCC;4DDDD%EF%
)
Fileappend,%AA%`n,%F1%
}
T1=200 ;column1 width
T2=100 ;column2 width
T3=100 ;column3 width
T4=100 ;column4 width
LSW:=(T1+T2+T3+T4+20) ;Listview width
GSW:=(LSW+30) ;GUI width
Gui,1:Add, ListView,x10 y10 h280 w%LSW% grid +hscroll nosorthdr altsubmit vMLV1A gMLV1B, AA|BB|CC|DD
LV_ModifyCol(1,T1)
LV_ModifyCol(2,T2)
LV_ModifyCol(3,T3)
LV_ModifyCol(4,T4)
gosub,SB
Gui,1:Show, x2 y0 w%GSW% h610,TEST FILEREAD
return
;-------------------------------
Guiclose:
exitapp
SB:
Gui,1:ListView,MLV1A
LV_Delete()
loop,read,%F1%
{
stringsplit,C,A_LoopReadLine,`;,
LV_Add("",C1,C2,C3,C4)
}
GC:=LV_GetCount()
LV_Modify(LV_GetCount(), "Vis") ;jumps to last row
;GuiControl,1:Text,TOT1,%GC%
LV_Modify(GC, "+Select +Focus") ;focus last row
return
;=================================================
;---------------------------------
;-----------------------------------------------
MLV1B:
Gui,1:Submit,nohide
Gui,1:ListView,MLV1A
RN:=LV_GetNext("C")
RF:=LV_GetNext("F")
GC:=LV_GetCount()
if A_GuiEvent=normal
return
;--------- DELETE multiple rows in text-file -----------
if A_GuiEvent = RightClick
{
CLL=
RF= 0
RFL=
Loop
{
RF:=LV_GetNext(RF)
if (RF="" OR RF=0)
break
RFL = %RF%|%RFL% ;yyy
LV_GetText(CLL_Temp,RF,1)
CLL = %CLL%`n%CLL_Temp%
}
if CLL !=
{
msgbox, 262452, DELETE,Want you delete lines in %F1%`n%CLL%?
IfMsgBox,No
Return
Else
{
Loop, parse, RFL, | ;yyy
LV_Delete(A_LoopField)
filedelete,%F1%
RFL=
CLL=
Loop % LV_GetCount()
{
BX1=
BX2=
BX3=
BX4=
LV_GetText(BX1,A_INDEX,1)
LV_GetText(BX2,A_INDEX,2)
LV_GetText(BX3,A_INDEX,3)
LV_GetText(BX4,A_INDEX,4)
e4=%e4%%BX1%`;%BX2%`;%BX3%`;%BX4%`r`n
}
Fileappend,%E4%,%F1%
e4=
}
}
Gosub,SB
return
}
return
another example ( I think not wanted) , like above
Code:
;-------- removexxx somelines in textfile which contains zzzz -----
F1=test1.txt
;ifexist,%f1%
; filedelete,%f1%
a4=
(
aaaa
bbbbzzzzccc
dddd
eeee
zzzz
ggggrrrr
)
stringreplace,a4,a4,`r,`r`n
ifnotexist,%f1%
Fileappend,%a4%,%f1%
S1=zzzz
FileRead, mveFile,%f1%
newFile =
Loop, Parse, mveFile, `n
{
IfNotInString, a_loopfield, %s1%
new1=%new1%%a_loopfield%
}
FileDelete, %f1%
FileAppend,%new1%,%f1%
run,%f1%
return
EDIT modified first script