Delete lines from log window by line numbers

From NSIS Wiki

Author: Afrow UK (talk, contrib)


Description

Here are two functions to delete selective lines from the installer log window.

Usage1

Before

DetailPrint "line1 from top"
DetailPrint "line2 from top"
DetailPrint "line3 from top"
DetailPrint "line4 from top"
Push "1,4"
Call DeleteFromTop

After

DetailPrint "line2 from top"
DetailPrint "line3 from top"

Usage2

Before

DetailPrint "line4 from end"
DetailPrint "line3 from end"
DetailPrint "line2 from end"
DetailPrint "line1 from end"
Push "2"
Call DeleteFromEnd

After

DetailPrint "line4 from end"
DetailPrint "line3 from end"
DetailPrint "line1 from end"

The Functions

Function DeleteFromTop
Exch $R0
Push $R1
Push $R2
 StrCpy $R2 0
loop:
 IntOp $R2 $R2 - 1
 StrCpy $R1 $R0 1 $R2
StrCmp $R1 "" +2
StrCmp $R1 , 0 loop
 IntOp $R2 $R2 + 1
 StrCpy $R1 $R0 "" $R2
 IntOp $R2 $R2 - 1
 StrCpy $R0 $R0 $R2
  IntOp $R1 $R1 - 1
  FindWindow $R2 "#32770" "" $HWNDPARENT
  GetDlgItem $R2 $R2 0x3F8
  SendMessage $R2 0x1008 $R1 0
 StrCmp $R0 "" exit
 StrCpy $R2 0
Goto loop
exit:
Pop $R2
Pop $R1
Pop $R0
FunctionEnd
Function DeleteFromEnd
Exch $R0
Push $R1
Push $R2
Push $R3
Push $R4
  FindWindow $R3 "#32770" "" $HWNDPARENT
  GetDlgItem $R3 $R3 0x3F8
  SendMessage $R3 0x1004 0 0 $R3
 StrCpy $R2 0
 StrCpy $R4 -1
loop:
 IntOp $R2 $R2 - 1
 StrCpy $R1 $R0 1 $R2
StrCmp $R1 "" +2
StrCmp $R1 , 0 loop
 IntOp $R2 $R2 + 1
 StrCpy $R1 $R0 "" $R2
 IntOp $R2 $R2 - 1
 StrCpy $R0 $R0 $R2
  IntOp $R1 $R3 - $R1
  IntOp $R4 $R4 + 1
  IntOp $R1 $R1 - $R4
  FindWindow $R2 "#32770" "" $HWNDPARENT
  GetDlgItem $R2 $R2 0x3F8
  SendMessage $R2 0x1008 $R1 0
 StrCmp $R0 "" exit
 StrCpy $R2 0
Goto loop
exit:
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Pop $R0
FunctionEnd

Functions created after this topic.

-Stu (Afrow UK)

Personal tools
donate