I have build my first PSPad script based on an draft from gogogadgetscott.
(Thank you)
With this script you can select some lines via PSPad script engine.
_Features:_
* Normal select hole lines
* Column select
* Go up n-lines and select this n-lines
* Go down n-lines and select this n-lines
_Purpose:_
If you have the need to select exactly n-lines and don't want to count
yourself.
_Program state:_
[color=red]_Alpha!!!_[/color]
I have tested it, but i can't test all the possibles that may happens.
So please test this script every time with an copy of your documents only!
_How to_
Save this code as an text file called e.g. GoToAndSel.vbs
in the PSPad script folder, f.ex.
"C:\PSPad\Script\VBScript"
"C:\PSPad\Script\VBScript\GoToAndSel.vbs"
Then start PSPad and test.
The script _GoToAndSel.vbs_
[color="blue"]
'// Purpose: Ask the user for the amount of lines
'// and select this amount of lines. This script works with hole lines only.
'// Use: Put cursor in your start line, then start the script and answer the
question.
'// Stefan Schuck, 05-2007. Based on an script "select.vbs" from
gogogadgetscott, Date: 07/27/2005
Const module_name = "GoTo_And_Select"
Const module_ver = "0.001"
Sub GoToUpAndSel
Set editor = newEditor()
vUserInput = InputBox("Enter lines to select up:" _
& vbCrLf & "(leave blank to select till top of file)",
module_name, "")
With editor
.assignActiveEditor
.command "ecDown"
.command "ecLineStart"
.command "ecSelLineStart"
If vUserInput = "" Then
vGoLinesAmount = .caretY
ELSE
vGoLinesAmount = vUserInput
End If
For i = vGoLinesAmount to 1 Step -1
.command "ecSelUp"
Next
End With
vUserInput=""
vGoLinesAmount=""
Set editor = Nothing
End Sub
'===============================================================================
=================='
Sub GoToDownAndSel
Set editor = newEditor()
vUserInput = InputBox("Enter lines to select down:" _
& vbCrLf & "(leave blank to select till end of file)",
module_name, "")
With editor
.assignActiveEditor
.command "ecLineStart"
.command "ecSelLineEnd"
If vUserInput = "" Then
vGoLinesAmount = .linesCount - .caretY
ELSE
vGoLinesAmount = vUserInput -1
End If
For i = vGoLinesAmount to 1 Step -1
.command "ecSelDown"
Next
.command "ecSelLineEnd"
End With
vUserInput=""
vGoLinesAmount=""
Set editor = Nothing
End Sub
'###############################################################################
###################'
'// Purpose: Ask the user for the amount of lines
'// and select this amount of lines. This script works with column only.
'// Use: Select part of line in your start line with your column width, then
start the script and answer the question.
'// Stefan Schuck, 05-2007. Based on an script "select.vbs" from
gogogadgetscott, Date: 07/27/2005
Sub GoToUpSelCol
Set editor = newEditor()
vUserInput = InputBox("Enter lines to select up:" _
& vbCrLf & "(leave blank to select till top of file)",
module_name, "")
With editor
.assignActiveEditor
.command "ecColumnSelect"
If vUserInput = "" Then
vGoLinesAmount = .caretY -1
ELSE
vGoLinesAmount = vUserInput
End If
For i = vGoLinesAmount to 1 Step -1
.command "ecSelUp"
Next
End With
vUserInput=""
vGoLinesAmount=""
Set editor = Nothing
End Sub
'===============================================================================
=================='
Sub GoToDownSelCol
Set editor = newEditor()
vUserInput = InputBox("Enter lines to select down:" _
& vbCrLf & "(leave blank to select till end of file)",
module_name, "")
With editor
.assignActiveEditor
' IF editor.selText = "" Then
' MsgBox "nothing selected"
' End If
.command "ecColumnSelect"
If vUserInput = "" Then
vGoLinesAmount = .linesCount - .caretY
ELSE
vGoLinesAmount = vUserInput -1
End If
For i = vGoLinesAmount to 1 Step -1
.command "ecSelDown"
Next
End With
vUserInput=""
vGoLinesAmount=""
Set editor = Nothing
End Sub
'###############################################################################
###################'
Sub Init
menuName = "&" & "Go to... (and select in between)"
addMenuItem "Go up and select lines" , menuName, "GoToUpAndSel"
',"Ctrl+Shift+Alt+U"
addMenuItem "Go up and select column" , menuName, "GoToUpSelCol"
addMenuItem "Go down and select lines" , menuName, "GoToDownAndSel"
',"Ctrl+Shift+ALt+D"
addMenuItem "Go down and select column" , menuName, "GoToDownSelCol"
End Sub
'EOF[/color]
I hope you have an use for it?
.
--
<http://forum.pspad.com/read.php?2,40607,40607>
PSPad freeware editor http://www.pspad.com