Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Note!
Dont place any non script files direct into script language subdirectories !
All files e.g. in VBScript subrirectory are consider as script and non script file causes compilation error.
modules library
You can write own library and share function from library in other scripts. Unique module_name is identifier.
To call function from other module, place module name before function name:
myLibrary.someFunction()
global functions/subroutines
addMenuItem(caption: string; submenu: string; procedure: string)
creates menu item in PSPad main menu. if you don't want submenu, send empty string as parameter
Its contained in script Init subroutine and works only during Init phase. All other calling is ignored.
echo(text: string)
information box with text and button OK
sleep(ms: integer)
setWaitCursor([boolean])
sets screen cursor to HourGlass (true parameter) and Default one (false parameter)
setClipboardText(text: string)
stores text into clipboard
getClipboardText(): string
returns text from clipboad
runPSPadAction(ActionName: string)
allows to run any PSPad editor action. List of actions follows.
getVariable(name: string)
reloadClips
logClear
clears whole LOG window content
logAddLine(test: string)
adds new line into LOG
logLinesCount(): Integer
returns current number of LOG window lines
logSetTypeMemo
sets LOG window type to memo style - you are able to make free selection, byt without error marks
logSetTypeList
sets LOG window type to list style - only line by line selection, but with error marks
pspadVersion(): string
returns PSPad version
moduleExists(name: string):boolean
returns True if script module exists
moduleVersion(name: string):string
returns version of module, if module doesn't exists, returns empty string
moduleFileName(name: string):string
returns file name of module, if module doesn't exists, returns empty string.
modulePath():string
closeAllEditors
closes all editor windows
editorsCount: integer
returns number of open editors
projectFilesCount: integer
returns number of files (not folders) in project. Use cycle from 0 to projectFilesCount-1
returns file name for index. If file doesn't exists, returns empty string
projectItemsCount: integer
returns number of all items (files and folders) in project. Use cycle from 0 to projectItemsCount-1
returns item name for index. If item doesn't exists, returns empty string
returns project item type. 1: folder, 2: file, -1: item doesn't exists
projectFileName: string
returns project file name
projectSave
saves project
ftpDisconnect
disconnect FTP server
ftpRefresh
newEditor(): object
creates new object for editor handling
assignActiveEditor(): boolean
assignLog(): boolean
this function is obsolete now. Is replaced with logXXXXX() functions. Now returns always 0, in the past
returns always 1
saveFile(): boolean
saves file
reloadFile(): boolean
reload file
closeFile(): boolean
closes file
activate(): boolean
brings editor to front
printFile(boolean): boolean
if parameters is 1 then PrintDialog appears before print
readOnly([boolean]): boolean
returns if no param or sets editor ReadOnly state
modified([boolean]): boolean
returns if no param or sets editor Modified state
text(string):string
replaces/returns all editor text
selText(string): string
replaces/returns selected text from editor
lineText(string): string
replaces/returns content of active line
linesCount(): integer
returns editor lines count
topLineIndex([integer]): integer
sets or returns returns index of the first line in editor window
linesInWindow(): integer
returns number of lines in editor window
appendText(string): boolean
appends text to editor end
fileName(string): string
sets/returns editor file name
caretX(integer): integer
sets/returns editor CaretX position
caretY(integer): integer
sets/returns editor CaretY position
editor
blockBeginX: integer
returns block start column
blockBeginY: integer
returns block start line
blockEndX: integer
returns block end column
blockEndY: integer
returns block end line
selStart(integer): integer
returns/sets block start
selLength(integer): integer
returns/sets block length
ecSelLeft
ecSelRight
ecSelUp
ecSelDown
ecSelWord
ecSelWordLeft
ecSelWordRight
ecSelLineStart
ecSelLineEnd
ecSelPageUp
ecSelPageDown
ecSelPageLeft
ecSelPageRight
ecSelPageTop
ecSelPageBottom
ecSelEditorTop
ecSelEditorBottom
ecLeft + ecSelection;
ecRight + ecSelection;
ecUp + ecSelection;
ecDown + ecSelection;
selects word under cursor
ecWordLeft + ecSelection;
ecWordRight + ecSelection;
ecLineStart + ecSelection;
ecLineEnd + ecSelection;
ecPageUp + ecSelection;
ecPageDown + ecSelection;
ecPageLeft + ecSelection;
ecPageRight + ecSelection;
ecPageTop + ecSelection;
ecPageBottom + ecSelection;
ecEditorTop + ecSelection;
ecEditorBottom + ecSelection;
ecScrollUp
ecScrollDown
ecScrollLeft
ecScrollRight
ecInsertMode
ecOverwriteMode
ecToggleMode
ecNormalSelect
ecColumnSelect
ecLineSelect
ecMatchBracket
go to matching bracket
ecGotoMarker0
...
ecGotoMarker9
ecSetMarker0
...
ecSetMarker9
goto marker
ecDeleteLastChar
ecDeleteChar
ecDeleteWord
ecDeleteLastWord
ecDeleteBOL
ecDeleteEOL
ecDeleteLine
ecClearAll
ecLineBreak
ecInsertLine
ecUndo
ecRedo
ecCut
ecPaste
ecSelectAll
ecCopy
ecBlockIndent
ecBlockUnindent
ecTab
ecShiftTab
indent selection
unindent selection
tab key
shift+Tab key
goto marker
set marker
set marker
ecUpperCase
apply to the current or previous word
ecLowerCase
ecToggleCase
ecTitleCase
ecUpperCaseBlock apply to current selection, or current char if no selection
ecLowerCaseBlock
ecToggleCaseBlock
aFullScreen
aGoogleSearch
aGotoLine
aGUID
aHexToDec
aHTMLCompress
aHtmlCheck
aHTMLPrev
aHTMLReformat
aHTMLSelTag
aIndent
aInfo
aInserFile
aInsertText
aInvertCase
aJoinLine
aLangHelp
aLastUserConvertor
aLineNum
aLogWindow
aLoremIpsum
aLowerCase
aMacroMgr
aMacroPlay
aMacroRecord
aMailContents
aMailFile
aMarkDown
aMarkList
aMarkUp
aMatchBracket
aMD5Gen
aMoveAs
aNew
aOpen
aOpenCopy
aOpenHex
aOpenSame
aOpenSelected
aOpenWWWFile
aPageSetup
aPaste
aPasteHTML
aPasteNoMove
aPrint
aPrintPrev
aPrintSetup
aProjAddOpen
aProjFolderClose
aProjFolderOpen
aProjFromDir
aProjInfo
aProjMainFile
aProjNew
aProjOpen
aProjSave
aProjSaveas
aProjSettings
aProjShow
aQuotedPrintToANSI
aReadOnly
aRedo
aReformat
aReformat2
aRemoveBlankLines
aRemoveFile
aRemoveRedundantBlank
aRemoveSpaces
aRemoveTags
aReOpen
aRepeatLastAction
aReplace
aRollBar
aRTFImport
aSave
aSaveAll
aSaveAs
aSaveBlock
aSaveSameTime
aSaveToFTP
aScriptsRecompile
aSelectAll
aSelectNext
aSelectPrew
aSelMatchBracket
aSelString
aSendToDisk
aSentensize
aSetMain
aSetMark
aShellOpen
aShowControlBar
aShowSpecChar
aSort
aSpell
aSpellCheck
aSpellSett
aStayOnTop
aSwapLineAbove
aSwapLineBellow
aSwapBlock
aSwitchLog
aSyntax
aSyntaxChange
aSysEdit
aTabToSpaces
aTagToLowercase
aTagToUpperCase
aTextToHTML
aToJScript
aToPHP
aUndo
aUnIndent
aUnQuote
aUpperCase
aURLToANSI
aUserConvertors
aWindCascade
aWindSplitHoriz
aWindSplitVert
aWindTile
aWindTileHoriz
aWindTileVert
aWordWrap
sample vb script
' it will create new editor window, copy all text from first window
into new
' and save new file as C:\SAMPLE.TXT
const module_name = "sample"
'this name must be unique !!!
const module_desc = "Sample script" 'script description
const module_ver
= "0.001a"
'version
sub Main
'main procedure
dim obj1, obj2, s
'variable definition
pspadVersion
msgbox "PSPad version : " & pspadVersion()
msgbox "Module version: " & moduleVersion("sample")
set obj1 = getNewEditor()
'new editor object
set obj2 = getNewEditor()
'new editor object
obj2.assignEditorByIndex(0)
'assign PSPad window 1 to obj2
obj1.NewFile()
'opens new file in PSPad and
assign to obj2
s = obj2.getText
'returns all text from window 1
obj1.settext(s)
'replaces all text in new window
' here is presented access to editor lines line by line
dim item
for each item in obj1
MsgBox item
next
obj1.saveFileAs("C:\sample.txt")
'save as new editor
obj1.closeFile
'close copy file
end sub
sub Demo1
msgbox "You run Demo1 from sample script"
end sub
sub Demo2
msgbox "You run Demo2 from sample script"
end sub
' name "Init" is required, its called automatically during
initialization to create menu items
sub Init
addMenuItem "Main from Sample", "", "Main"
addMenuItem "Demo1 from Sample","Sample - submenu", "Demo1"
addMenuItem "Demo2 from Sample","Sample - submenu", "Demo2"
end sub
= "RunAction"
= "0.001"
sub Procedure
set obj = NewEditor()
for i = 0 to editorsCount - 1
obj.assignEditorByIndex(i)
obj.activate
if i = 0 then 'for first file we call user convertor selector
runPSPadAction "aUserConvertors"
else
'for all other files we run last used convertor
runPSPadAction "aLastUserConvertor"
end if
next
end sub
' name "Init" is required, its called automatically during
initialization to create menu items
sub Init
addMenuItem "Run action demo (convert all open files)","", "Procedure"
end sub