 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
PaulW Guest
|
Posted: Mon Mar 15, 2010 10:10 pm Post subject: Deleting entries from TXT file. |
|
|
I'm playing with this script.
http://www.autohotkey.com/forum/post-44471.html#44471
If I change the file type from CSV to TXT and then delete an entry I always end up with a blank line, directly after the deleted entry.
Any way to just delete the line with out the carriage return or blank line preceding it ?
The delete function is:
| Code: | Delete:
RowNumber := LV_GetNext(0)
if not RowNumber
Return
Loop, 5
LV_GetText(A3%A_Index%, RowNumber,A_Index)
Msgbox,4,, Are you sure to delete ?
Ifmsgbox, No
return
Loop, % Line0 - A35 + 1
{
ID := A_Index + A35 - 1
IDNext := ID + 1
Line%ID% := Line%IDNext%
}
Line0--
GoSub,FILLLIST
return |
Thanks  |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 2214 Location: switzerland
|
Posted: Tue Mar 16, 2010 7:08 am Post subject: |
|
|
I see no difference between TXT or CSV
here an example
-delete multiple marked lines with rightclick
| Code: | MODIFIED=20100316
;------ LV DELETE marked lines with rightclick -------
;------- 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
}
if e4=
Filedelete,%f1%
else
Fileappend,%E4%,%F1%
e4=
RFL=
CLL=
}
}
Gosub,SB
return
}
return
|
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|