Author Topic: Example Script [Not working]: Filter Lines to new document  (Read 1510 times)

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
Example Script [Not working]: Filter Lines to new document
« on: September 27, 2009, 08:18:54 PM »
Hi all.

To see what is possible by an script
and what is needed from the editor script engine
i post here some test scripts.

Please note that this scripts are NOT written for HippoEDIT right now
and that HippoEDIT didn't even have an scripting support implemented right now.
(script will be converted once HippoEDIT scripting support is implemented)

* i am not an programmer,
* that script may not be well designed (mostly i am have less interest if my script works "fair to middling"
    to clean it up, because of i had to do other things is more important mostly)
* test my scripts with test files only
* i give no guarantee that your files are not deleted
   and that your computer will not gonna implode.

* the scripts are free to use and to modify. But please respect the copyright mentions inside the scripts.

(If YOU want to post scripts too, please add an disclaimer as mine too.
You could even use mine for non-working scripts)

Example Script [Not working]: Filter Lines to new document

I think i have found this script my self in the other forum?!
I mean i have converted this from JS to VBS.

This script take an look on each line
and if the line contain an WORD (or not)
this line is copied to an new opened/created tab/document.

Code: [Select]
module_name = "FilterLines"
module_ver = "0.001a"

Function Init
  addMenuItem "Filter For Selection VBS", "Filter lines", "FilterForSelection"
  addMenuItem "Filter Out Selection VBS", "Filter lines", "FilterOutSelection"
End Function

Sub FilterForSelection()
Dim editor
Set editor = newEditor()
If editor Is Nothing Then Exit Sub

Dim NewEd
Set NewEd = newEditor()

  'sel = editor.selText()
  Set rex = new RegExp
      With Rex
          .Pattern = editor.selText()
          .IgnoreCase = True
          .Global = True
      End With
          'msgbox rex.pattern
  AllLines = editor.Text()
  LineArray = split(AllLines, EOL) ' "\n")
            For i = 0 To UBound(LineArray)
                Line = LineArray(i)
                Set match = rex.execute(Line)
                'msgbox match.Count
                  If Match.Count < 0 Then

                  End If
  Set Rex  = nothing
End Sub

' /*
' Function FilterOutSelection()
'   var edLog = newEditor();
'   edLog.assignActiveEditor();
'   var edFilter = newEditor();
'   edFilter.NewFile();
'   var d = edLog.selText();
'   var r = new RegExp(d, i);
'   var s = edLog.Text();
'   var l = s.split("\n");
'   var i;
'   for (i in l)
'   {
'     var t = l[i];
'     var x =;
'     if (x < 0)
'     {
'       edFilter.appendText(t);
'     }
'   }
' }
' End Function
' */
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-