You are here: PSPad forum > English discussion forum > Re: my tool : LinesFilter

Re: my tool : LinesFilter

#1 my tool : LinesFilter

Posted by: candide | Date: 2019-01-25 17:56 | IP: IP Logged

hi

i would like to share with you a tool i created : LinesFilter

i use this tool to filter larges log files or traces to find what i need. I tested it on file 40 MBytes, it can take 20sec on my PC by command, but it is working.

it is a script in VBS added at PSPad and i can use it from menu. First i have to open file to filter and after i can run:
- init => first command to create temporary files
- all "string" => only lines with "string" will be in editor view
- all => full file is in editor view
- more "string" => lines with "string" are added in editor view
- less "string" => all lines with "string" in editor view are removed
- revers => we revers selection in editor view
- delete "string" => all lines with "string" in editor view are deleted
- delete => all lines in editor view are deleted
- change "string1" "string2" => in editor view all lines with "string1" are changed with "string2"
- change "string" => in editor view "string1" is removed in all lines
- end => temporary files are deleted
- byBatchFile => you can load a file with one command by line to run an automatic list of command on your text file

script and an example of command file are here:
drive.google.com

script is below but i am not sure is OK in a post
'====================================================='
' it is a script to sort/filter a file by line, to concentrate focus on interesting lines
' it is ideal tool to manage very large like log files of traces files
'====================================================='
option explicit
const module_name = "LinesFilter" 'this name must be unique !!!
const module_desc = "Multiline management" 'script description
const module_ver = "0.002" 'version 2 basée sur des fichiers disque
Const ForReading = 1, ForWriting = 2, ForAppending = 8

public select1, select2, vers, i
public obj1, obj2, linemax, sel1, sel2, line1
public Tfso, Tf0, Tf1, Tf2, TF3, TF4, Tf5, Ts0, Ts1, Ts2, Ts3, Ts4, Ts5

Ts0 = (getVarValue("%AppData%")+"\PSpad\multiobj1.txt") 'original file'
Ts1 = (getVarValue("%AppData%")+"\PSpad\multiobj2_1.txt") 'selection in file'
Ts3 = (getVarValue("%AppData%")+"\PSpad\multiselect1.txt") 'list of lines selected
Ts2 = (getVarValue("%AppData%")+"\PSpad\multiobj2_2.txt") 'temporary file'
Ts4 = (getVarValue("%AppData%")+"\PSpad\multiselect2.txt") 'temporary file'
Ts5 = (getVarValue("%AppData%")+"\PSpad\multiobj1_1.txt") 'temporary file'
Set Tfso = CreateObject("Scripting.FileSystemObject")
vers = 0

'=============================================='
sub Main
'=============================================='
set obj1 = NewEditor() 'new editor object
set obj2 = NewEditor() 'new editor object

obj1.assignActiveEditor 'assign PSPad window active to obj1
logclear
obj2.NewFile() 'opens new file in PSPad and assign to obj2
obj2.text(obj1.text) 'filename
If not(Tfso.FolderExists(getVarValue("%AppData%")+"\PSpad")) Then Tfso.CreateFolder(getVarValue("%AppData%")+"\PSpad")
If (Tfso.FileExists(Ts0)) Then Tfso.DeleteFile(Ts0)
If (Tfso.FileExists(Ts1)) Then Tfso.DeleteFile(Ts1)
obj2.saveFileAs(Ts0)
obj2.saveFileAs(Ts1)
linemax = obj2.linescount
If (Tfso.FileExists(Ts2)) Then Tfso.DeleteFile(Ts2)
Set Tf2 = Tfso.OpenTextFile(Ts2, Forwriting, True)
for i = 0 to linemax
Tf2.writeline "1"
next
Tf2.close

logaddline("temporary file used :"+ Ts1)
logaddline("temporary file used :"+ Ts2)
logaddline("temporary file used :"+ Ts3)
logaddline("temporary file used :"+ Ts4)
logaddline("temporary file used :"+ Ts5)
logaddline("[init] command Done, new editor created")
logaddline("new editor is 'readonly' until [End] command")
obj2.readonly(true)
end sub

'=============================================='
sub all_ln
'=============================================='
set obj2 = NewEditor() 'new editor object
obj2.assignEditorByName(Ts1) 'assign deuxième fichier

if vers = 0 then
if (editorsCount() > 0) then select1 = obj2.selText()
select1 = inputbox("only lines with text below are selected"+vbcrlf+vbcrlf+"if no text, all lines from original file are selected","[All] command",select1)
if select1 ="" then
if (msgbox("do you want to make a selection with full file ?",1,"[All] command") = 2) then exit sub
end if
end if

''cas 1 si pas de texte: la sélection reprend tout le fichier de référence
if select1 ="" then
If (Tfso.FileExists(Ts1)) Then Tfso.DeleteFile(Ts1)
Tfso.CopyFile Ts0,Ts1
obj2.openfile(Ts1)
linemax = obj2.linescount
'on remet la selection de toutes les lignes a 1'
If (Tfso.FileExists(Ts2)) Then Tfso.DeleteFile(Ts2)
Set Tf2 = Tfso.OpenTextFile(Ts2, Forwriting, True)
for i = 0 to linemax
Tf2.writeline "1"
next
Tf2.close
else
'cas 2 texte fourni: la selection ne reprend que les lignes contenant le texte donné'
Set Tf1 = Tfso.OpenTextFile(Ts1, ForReading, True) 'fichier backup obj2'
Set Tf2 = Tfso.OpenTextFile(Ts2, ForReading, True) 'selection backup obj2'
If (Tfso.FileExists(Ts3)) Then Tfso.DeleteFile(Ts3) 'next fichier pour obj2'
Set Tf3 = Tfso.OpenTextFile(Ts3, Forwriting, True)
If (Tfso.FileExists(Ts4)) Then Tfso.DeleteFile(Ts4) 'next selection pour obj2'
Set Tf4 = Tfso.OpenTextFile(Ts4, Forwriting, True)
Do While Tf1.AtEndOfStream <> True
line1 = Tf1.readline
sel1 = Tf2.readline
sel2 = sel1
if sel1 = "1" then
if instr(line1,select1) < 1 then sel2 = "0"
end if
if sel2 = "1" then Tf3.writeline line1
Tf4.writeline sel2
loop
Tf1.close
Tf2.close
Tf3.close
Tf4.close
If (Tfso.FileExists(Ts1)) Then Tfso.DeleteFile(Ts1) 'fichier pour obj2'
If (Tfso.FileExists(Ts2)) Then Tfso.DeleteFile(Ts2) 'next fichier pour obj2'
Tfso.CopyFile Ts3,Ts1
Tfso.CopyFile Ts4,Ts2
Tfso.Deletefile(Ts3)
Tfso.Deletefile(Ts4)
obj2.openfile (Ts1)
end if
obj2.activate
logaddline("[All] command done")
vers = 0
end sub

'=============================================='
sub moreln
'=============================================='
set obj2 = NewEditor() 'new editor object
obj2.assignEditorByName(Ts1) 'assign deuxième fichier

if vers = 0 then
if (editorsCount() > 0) then select1 = obj1.selText()
select1 = inputbox("all lines with text below are added at selection","[More] command",select1)
end if

if select1 ="" then exit sub
'cas texte fourni: on ajoute à la selection les lignes du fichier d'origine contenant le texte donné'
Set Tf0 = Tfso.OpenTextFile(Ts0, ForReading, True) 'fichier backup obj1'
'' Set Tf1 = Tfso.OpenTextFile(Ts1, ForReading, True) 'fichier backup obj2'
Set Tf2 = Tfso.OpenTextFile(Ts2, ForReading, True) 'selection backup obj2'
If (Tfso.FileExists(Ts3)) Then Tfso.DeleteFile(Ts3) 'next fichier pour obj2'
Set Tf3 = Tfso.OpenTextFile(Ts3, Forwriting, True)
If (Tfso.FileExists(Ts4)) Then Tfso.DeleteFile(Ts4) 'next selection pour obj2'
Set Tf4 = Tfso.OpenTextFile(Ts4, Forwriting, True)
Do While Tf0.AtEndOfStream <> True
line1 = Tf0.readline
sel1 = Tf2.readline
sel2 = sel1
if sel1 = "0" then
if instr(line1,select1) > 0 then sel2 = "1"
end if
if sel2 = "1" then Tf3.writeline line1
Tf4.writeline sel2
loop
Tf0.close
Tf2.close
Tf3.close
Tf4.close
If (Tfso.FileExists(Ts1)) Then Tfso.DeleteFile(Ts1) 'fichier pour obj2'
If (Tfso.FileExists(Ts2)) Then Tfso.DeleteFile(Ts2) 'next fichier pour obj2'
Tfso.CopyFile Ts3,Ts1
Tfso.CopyFile Ts4,Ts2
Tfso.Deletefile(Ts3)
Tfso.Deletefile(Ts4)
obj2.openfile (Ts1)
obj2.activate
logaddline("[More] command done")
vers = 0
end sub

'=============================================='
sub lessln
'=============================================='
set obj2 = NewEditor() 'new editor object
obj2.assignEditorByName(Ts1) 'assign deuxième fichier

if vers = 0 then
if (editorsCount() > 0) then select1 = obj2.selText()
select1 = inputbox("lines with text below are removed from selection","[Less] command",select1)
end if

if select1 ="" then exit sub
'cas texte fourni: les lignes contenant le texte donné sont retirées de la selection'
Set Tf0 = Tfso.OpenTextFile(Ts0, ForReading, True) 'fichier backup obj1'
'' Set Tf1 = Tfso.OpenTextFile(Ts1, ForReading, True) 'fichier backup obj2'
Set Tf2 = Tfso.OpenTextFile(Ts2, ForReading, True) 'selection backup obj2'
If (Tfso.FileExists(Ts3)) Then Tfso.DeleteFile(Ts3) 'next fichier pour obj2'
Set Tf3 = Tfso.OpenTextFile(Ts3, Forwriting, True)
If (Tfso.FileExists(Ts4)) Then Tfso.DeleteFile(Ts4) 'next selection pour obj2'
Set Tf4 = Tfso.OpenTextFile(Ts4, Forwriting, True)
Do While Tf0.AtEndOfStream <> True
line1 = Tf0.readline
sel1 = Tf2.readline
sel2 = sel1
if sel1 = "1" then
if instr(line1,select1) > 0 then sel2 = "0"
end if
if sel2 = "1" then Tf3.writeline line1
Tf4.writeline sel2
loop
Tf0.close
Tf2.close
Tf3.close
Tf4.close
If (Tfso.FileExists(Ts1)) Then Tfso.DeleteFile(Ts1) 'fichier pour obj2'
If (Tfso.FileExists(Ts2)) Then Tfso.DeleteFile(Ts2) 'next fichier pour obj2'
Tfso.CopyFile Ts3,Ts1
Tfso.CopyFile Ts4,Ts2
Tfso.Deletefile(Ts3)
Tfso.Deletefile(Ts4)
obj2.openfile (Ts1)
obj2.activate
logaddline("[Less] command done")
vers = 0
end sub

'=============================================='
sub revers
'=============================================='
set obj2 = NewEditor() 'new editor object
obj2.assignEditorByName(Ts1) 'assign deuxième fichier

if vers = 0 then
if (msgbox("do you want to revers selection ?",1,"[Revers] command") = 2) then exit sub
end if

'cas texte fourni: les lignes contenant le texte donné sont retirées de la selection'
Set Tf0 = Tfso.OpenTextFile(Ts0, ForReading, True) 'fichier backup obj1'
'' Set Tf1 = Tfso.OpenTextFile(Ts1, ForReading, True) 'fichier backup obj2'
Set Tf2 = Tfso.OpenTextFile(Ts2, ForReading, True) 'selection backup obj2'
If (Tfso.FileExists(Ts3)) Then Tfso.DeleteFile(Ts3) 'next fichier pour obj2'
Set Tf3 = Tfso.OpenTextFile(Ts3, Forwriting, True)
If (Tfso.FileExists(Ts4)) Then Tfso.DeleteFile(Ts4) 'next selection pour obj2'
Set Tf4 = Tfso.OpenTextFile(Ts4, Forwriting, True)
Do While Tf0.AtEndOfStream <> True
line1 = Tf0.readline
sel1 = Tf2.readline
if sel1 = "1" then sel2 = "0" else sel2 = "1"
if sel2 = "1" then Tf3.writeline line1
Tf4.writeline sel2
loop
Tf0.close
Tf2.close
Tf3.close
Tf4.close
If (Tfso.FileExists(Ts1)) Then Tfso.DeleteFile(Ts1) 'fichier pour obj2'
If (Tfso.FileExists(Ts2)) Then Tfso.DeleteFile(Ts2) 'next fichier pour obj2'
Tfso.CopyFile Ts3,Ts1
Tfso.CopyFile Ts4,Ts2
Tfso.Deletefile(Ts3)
Tfso.Deletefile(Ts4)
obj2.openfile (Ts1)
obj2.activate
logaddline("[Revers] command done")
vers = 0
end sub

'=============================================='
sub change
'=============================================='
set obj2 = NewEditor() 'new editor object
obj2.assignEditorByName(Ts1) 'assign deuxième fichier

if vers = 0 then
if (editorsCount() > 0) then select1 = obj2.selText()
replacebox '("search and replace selected text by provided text","[More] command",select1)
end if

if select1 ="" then exit sub
'cas texte fourni: dans la selection les lignes contenant le texte sont modifiées'
Set Tf0 = Tfso.OpenTextFile(Ts0, ForReading, True) 'fichier backup obj1'
If (Tfso.FileExists(Ts5)) Then Tfso.DeleteFile(Ts5) 'next fichier pour obj1'
Set Tf5 = Tfso.OpenTextFile(Ts5, Forwriting, True) 'bext fichier obj1'
Set Tf2 = Tfso.OpenTextFile(Ts2, ForReading, True) 'selection backup obj2'
If (Tfso.FileExists(Ts3)) Then Tfso.DeleteFile(Ts3) 'next fichier pour obj2'
Set Tf3 = Tfso.OpenTextFile(Ts3, Forwriting, True)
If (Tfso.FileExists(Ts4)) Then Tfso.DeleteFile(Ts4) 'next selection pour obj2'
Set Tf4 = Tfso.OpenTextFile(Ts4, Forwriting, True)
Do While Tf0.AtEndOfStream <> True
line1 = Tf0.readline
sel1 = Tf2.readline
sel2 = sel1
if sel1 = "1" then line1 = replace(line1,select1,select2)
if sel2 = "1" then Tf3.writeline line1
Tf4.writeline sel2
Tf5.writeline line1
loop
Tf0.close
Tf2.close
Tf3.close
Tf4.close
Tf5.close
If (Tfso.FileExists(Ts1)) Then Tfso.DeleteFile(Ts1) 'fichier pour obj2'
If (Tfso.FileExists(Ts2)) Then Tfso.DeleteFile(Ts2) 'next fichier pour obj2'
If (Tfso.FileExists(Ts0)) Then Tfso.DeleteFile(Ts0) 'fichier pour obj1'
Tfso.CopyFile Ts3,Ts1
Tfso.CopyFile Ts4,Ts2
Tfso.CopyFile Ts5,Ts0
Tfso.Deletefile(Ts3)
Tfso.Deletefile(Ts4)
Tfso.Deletefile(Ts5)
obj2.openfile (Ts1)
obj2.activate
logaddline("[Change] command done")
logaddline("****** both files are modified ********")
vers = 0
end sub

'=============================================='
sub delete ' case 1: delete all line case 2: delete lines with string
'=============================================='
set obj2 = NewEditor() 'new editor object
obj2.assignEditorByName(Ts1) 'assign deuxième fichier

if vers = 0 then
if (editorsCount() > 0) then select1 = obj2.selText()
select1 = inputbox("lines with text below in selection are definitively removed from both files"+vbcrlf+vbcrlf+"if no text, the selection will be deleted in both files","[Delete] command",select1)
if select1 = "" then
if (msgbox("do you want to remove all lines in selection ?",1,"[All] command") = 2) then exit sub
else
if (msgbox("do you want to remove lines in selection whith "+select1+" ?",1,"[All] command") = 2) then exit sub
end if
end if

'cas texte fourni: les lignes contenant le texte sont retirées de la selection et du fichier de départ'
'cas pas de text fourni : on supprime toute la selection'
Set Tf0 = Tfso.OpenTextFile(Ts0, ForReading, True) 'fichier backup obj1'
'' Set Tf1 = Tfso.OpenTextFile(Ts1, ForReading, True) 'fichier backup obj2'
Set Tf2 = Tfso.OpenTextFile(Ts2, ForReading, True) 'selection backup obj2'
If (Tfso.FileExists(Ts3)) Then Tfso.DeleteFile(Ts3) 'next fichier pour obj2'
Set Tf3 = Tfso.OpenTextFile(Ts3, Forwriting, True)
If (Tfso.FileExists(Ts4)) Then Tfso.DeleteFile(Ts4) 'next selection pour obj2'
Set Tf4 = Tfso.OpenTextFile(Ts4, Forwriting, True)
If (Tfso.FileExists(Ts5)) Then Tfso.DeleteFile(Ts5) 'next selection pour obj2'
Set Tf5 = Tfso.OpenTextFile(Ts5, Forwriting, True)

Do While Tf0.AtEndOfStream <> True
line1 = Tf0.readline
sel1 = Tf2.readline
sel2 = sel1
if sel1 = "1" then
if instr(line1,select1) > 0 then sel2 = "2"
if select1 = "" then sel2 = "2"
end if
if sel2 <> "2" then
Tf5.writeline line1
Tf4.writeline sel2
end if
if sel2 = "1" then Tf3.writeline line1
loop
Tf0.close
Tf2.close
Tf3.close
Tf4.close
Tf5.close
If (Tfso.FileExists(Ts1)) Then Tfso.DeleteFile(Ts1) 'fichier pour obj2'
If (Tfso.FileExists(Ts2)) Then Tfso.DeleteFile(Ts2) 'next fichier pour obj2'
If (Tfso.FileExists(Ts0)) Then Tfso.DeleteFile(Ts0) 'fichier pour obj1'
Tfso.CopyFile Ts3,Ts1
Tfso.CopyFile Ts4,Ts2
Tfso.CopyFile Ts5,Ts0
Tfso.Deletefile(Ts3)
Tfso.Deletefile(Ts4)
Tfso.Deletefile(Ts5)
obj2.openfile (Ts1)
obj2.activate
logaddline("[Delete] command done")
logaddline("****** both files are modified ********")
vers = 0
end sub

'=============================================='
sub allend
'=============================================='
If (Tfso.FileExists(Ts5)) Then Tfso.DeleteFile(Ts5) 'fichier pour obj2'
If (Tfso.FileExists(Ts4)) Then Tfso.DeleteFile(Ts4) 'next fichier pour obj2'
If (Tfso.FileExists(Ts3)) Then Tfso.DeleteFile(Ts3) 'fichier pour obj1'
If (Tfso.FileExists(Ts2)) Then Tfso.DeleteFile(Ts2) 'fichier pour obj2'
If (Tfso.FileExists(Ts1)) Then Tfso.DeleteFile(Ts1) 'next fichier pour obj2'
If (Tfso.FileExists(Ts0)) Then Tfso.DeleteFile(Ts0) 'fichier pour obj1'
logaddline("temporary file deleted :")
logaddline("'readonly' removed on obj2 Editor")
logaddline("[End] command done")
set obj2 = NewEditor() 'new editor object
obj2.assignEditorByName(Ts1) 'assign deuxième fichier
obj2.readonly(false)
vers = 0
end sub

'=============================================='
sub bybatch
'=============================================='
dim nfile, Tfa, line, mycom , deli, para1, para2
nfile = replace(GetFileNameDlg(),chr(13)+chr(10),"")
if nfile = "" then exit sub
Set Tfa = Tfso.OpenTextFile(nfile, ForReading, True)
if Tfa.AtEndOfStream <> True then line = split(Tfa.readline + " "," " )
mycom = trim(line(0))
if mycom <> "#init" then exit sub
deli = trim(line(1))
msgbox ("command: ["+mycom+"]"+vbcrlf+"separator: ["+ deli+"]")
main
sleep 500

Do While Tfa.AtEndOfStream <> True
line = split(Tfa.readline +deli+deli+deli+deli,deli)
mycom = trim(line(0))
para1 = (line(1))
para2 = (line(3))
if msgbox ("command: ["+mycom+"]"+vbcrlf+"selection1: [" +para1+"]"+vbcrlf+"selection2: [" +para2+"]",1)= 2 then exit do
vers = 1
select1 = para1
select2 = para2
select case mycom
case "#all"
all_ln

case "#more"
moreln

case "#less"
lessln

case "#revers"
revers

case "#change"
change

case "#delete"
delete

case "#end"
allend

case else msgbox("command error :"+ mycom)
end select
sleep 500
loop
Tfa.close
end sub

'=============================================='
'edition du scrip
'=============================================='
sub openScript
set obj1 = newEditor()
obj1.openFile(moduleFileName("LinesFilter") )
end sub

'=============================================='
'GetFileNameDlg
'=============================================='
Function GetFileNameDlg()
GetFileNameDlg=CreateObject("WScript.Shell").Exec("mshta.exe ""about:<input type=file id=f><script language=""VBScript"">f.click():CreateObject(""Scripting.FileSystemObject"").GetStandardStream(1).WriteLine(f.value):close()</script>""").StdOut.ReadAll
End Function

Class login
'************************************************************************************************************************************************************
'affiche un dialogue contenant 2 champs de text, un bouton Abort et un Bouton OK - omen999.developpez.com - février 2013
'************************************************************************************************************************************************************
Private sScript,sAbout,oHta,bIsPgBar,bUserShft,lpShift,oShell
Public lHeight,lWidth,lLeft,lTop
Private Sub Class_Initialize()'maj des valeurs par défaut
lHeight=180:lWidth=400:lLeft=0:lTop=0
End Sub
Public Default Function Display(sTitle,sMsg,bWithEvents)
Dim spTitle
spTitle="Login dialog - omen999.developpez.com"
If sTitle<>"" Then spTitle=sTitle
If bIsPgBar And Not(bUserShft) Then lpShift=1
sScript="var cOut=new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1),fg=false;document.title='"&spTitle&"';"&_
"resizeTo("&lWidth&","&lHeight&");moveTo("&lLeft&"+("&lLeft&"==0)*(screen.width-"&lWidth&")/2,"&lTop&"+("&lTop&"==0)*(screen.height-"&lHeight&")/2);"&_
"function window.onload(){bdy.className='cs';idt.size=55;mdp.size=55;idt.style.height='20px';idt.tabIndex=1;mdp.style.height='20px';"&_
"idt.innerText='"&sMsg&"';l1.innerText='Text to search';l2.innerText='To replace by :';btn.style.width='80px';btn.style.height='24px';"&_
"btn.innerHTML='<U>O</U>k';btn.style.position='absolute';btn.style.top='79%';btn.style.left='70%';btn.attachEvent('onclick',btn_onclick);idt.focus();"&_
"btn2.innerHTML='<U>C</U>ancel';btn2.style.position='absolute';btn2.style.top='79%';btn2.style.left='40%';btn2.attachEvent('onclick',btn2_onclick);btn2.style.width='80px';btn2.style.height='24px';}"&_
"function btn_onclick(){cOut.Write('005close003idt'+('00'+ idt.value.length).slice(-3)+idt.value+'005close003mdp'+('00'+ mdp.value.length).slice(-3)+mdp.value);close()};"&_
"function btn2_onclick(){cOut.Write('005abort003idt'+('00'+ idt.value.length).slice(-3)+idt.value+'005abort003mdp'+('00'+ mdp.value.length).slice(-3)+mdp.value);close()};"&_
"function sendEvent(){var e=event.type,i=event.srcElement.id,v;switch(e){"&_
"case 'blur':v=event.srcElement.value;if(v==''){eval(i + '.focus()');return;}break;"&_
"case 'keypress':v=(event.keyCode).toString();}"&_
"cOut.Write(('00'+ e.length).slice(-3)+e+('00'+ i.length).slice(-3)+i+('00'+ v.length).slice(-3)+v);readIn()}"&_
"function readIn(){var h1,h2,h3,id,dn,ds,fo,ne;h1=parseInt(cIn.Read(3),10);if((!isNaN(h1))&&(h1>0)){id=cIn.Read(h1);"&_
"h2=parseInt(cIn.Read(3),10);if(!isNaN(h2)){dn=parseInt(cIn.Read(h2),10);"&_
"h3=parseInt(cIn.Read(3),10);if(!isNaN(h3)){ds=cIn.Read(h3);if(ds=='#cls#'){close();}"&_
"if(eval(id + '.tagName')=='LABEL'){eval(id + '.innerText=""'+ ds +'""');}else{if(id=='mdp'){setTimeout(function(){setInput(id,ds)},10);}else{eval(id + '.value=""' + ds + '""');} }"&_
"fo=cIn.Read(1);ne=cIn.Read(1);"&_
"if(fo==1){eval(id + '.focus()');}"&_
"if(ne==1){readIn();}}}}}"&_
"function setInput(id,ds){eval(id + '.value=""' + ds + '""');}"
'maxsize sAbout string : 508 octets current : 507 octets
sAbout= "about:<SCRIPT>var cIn=new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(0);eval(cIn.Read("&Len(sScript)&"));</SCRIPT><HTA:APPLICATION SHOWINTASKBAR=""no"" SCROLL=""no"" SYSMENU=""no"" BORDER=""dialog"" INNERBORDER=""no""><HEAD><STYLE>.cs{font: 10px MS Sans Serif;background-color:'#E0E0E0';line-height:20px;}</STYLE></HEAD><BODY ID=""bdy""><LABEL ID=""l1"" FOR=""idt""></LABEL><BR><INPUT ID=""idt"" TYPE=""TEXT""><BR><LABEL ID=""l2"" FOR=""mdp""></LABEL><BR><INPUT ID=""mdp"" TYPE=""TEXT""><BR><BUTTON ID=""btn"">BR<BUTTON ID=""btn2""></BUTTON></BODY>"
Set oShell=CreateObject("WScript.Shell")
Set oHta=oShell.Exec("mshta.exe """ & sAbout & """")
oHta.StdIn.Write sScript
Set Display=oHta
End Function
Public Function SetOnEvent(sID,sDataN,sDataS,bSetFocus,bNext)
On Error Resume Next
oHta.StdIn.Write Right("00"&CStr(Len(sID)),3) & sID & Right("00"&CStr(Len(sDataN)),3) & sDataN & Right("00"&CStr(Len(sDataS)),3) & sDataS & bSetFocus & bNext
SetOnEvent=Err.Number
On Error GoTo 0
End Function
Public Function GetEvent(aData)
With oHta.StdOut
GetEvent=.Read(.Read(3)):aData(0)=.Read(.Read(3)):aData(1)=.Read(.Read(3))
End With
End Function
Public Sub Close()
SetOnEvent "bdy","","#cls#",0,0
End Sub
Public Sub Kill()
oHta.Terminate
End Sub
End Class

' ****************************** Lancement NON MODAL SANS EVENEMENTS
sub replacebox
Dim oLog,oEx,oSOut,aData(1)
Dim sID,sEvent,sValue,aID,sIdt,sMdp
Set oLog=New login
Set oEx=oLog.Display("[SEARCH/REPLACE] box",select1,0)
Do While oEx.Status=0
' insérez ici le code à exécuter pendant l'affichage du dialogue
Sleep 50
Loop
sEvent = oLog.GetEvent( aData)
Select Case sEvent
Case "close"
'' oLog.GetEvent aData
select1=aData(1)
oLog.GetEvent aData
select2=aData(1)
'' MsgBox "text a trouver: " & select1 & vbCrLf & "text nouveau: " & select2,,"resultat de search/replace"
Case "abort"
select1 = ""
'' Msgbox "Abort"
End Select
end sub

'=============================================='
sub Init
'=============================================='

addMenuItem "1-Init" ,"LinesFilter" , "main"
addMenuItem "2-All" ,"LinesFilter" , "all_ln"
addMenuItem "3-More" ,"LinesFilter" , "moreln"
addMenuItem "4-Less" ,"LinesFilter" , "lessln"
addMenuItem "5-Revers" ,"LinesFilter" , "revers"
addMenuItem "6-Change" ,"LinesFilter" , "change"
addMenuItem "7-Delete" ,"LinesFilter" , "delete"
addMenuItem "8-End" ,"LinesFilter" , "allend"
addMenuItem "byBatchFile" ,"LinesFilter" , "bybatch"
addMenuItem "ViewScript" ,"LinesFilter" , "openScript"
end sub
'dernière ligne

Options: Reply | Quote | Up ^


#2 Re: my tool : LinesFilter

Posted by: pspad | Date: 2019-01-26 07:26 | IP: IP Logged

Thank you for sharing

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2019 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR