The ActiveDocument object is used to refer to the document currently being displayed in the editor. To access an open document that isn't active, use the Application.DocumentCache object.
True if changes can be re-done.
True if changes can be undone.
Filename of the active document.
Gets/sets the text of the line at the passed index.Iterating through a document using the Lines property may be slow, especially for large documents. Allaire recommends that you only use Lines to evaluate single lines of text. If you must use Lines to update many lines, you can boost performance by wrapping the update in a BeginUpdate..EndUpdate
block.
Number of lines in the active document.
True if the document has been changed since it was last saved.
True if the active document is read-only.
Gets/sets the start of the current selection.
Gets/sets the length of the current selection
Gets/sets the text in the current selection.
Gets/sets the tab index of the document tab.
Gets/sets the complete document text.
procedure BeginUpdate()
Turns off screen updating for the active document. This is useful if your script needs to make several changes to the active document at once -- turning off screen updating during the procedure might significantly speed up the process. To turn updating back on, use EndUpdate
.
Use BeginUpdate...EndUpdate
with caution. If you fail to call EndUpdate
after a call to BeginUpdate
, or if the script crashes before EndUpdate
is called, the user will be unable to see any changes made in the editor.
procedure Clear()
Clears all text from the active document.
function Close(wbPromptToSave: WordBool): WordBool
Closes the active document. If wbPromptToSave
is True, the user is prompted to save any changes. Returns True if the document was closed (that is, the user didn't cancel saving changes).
procedure EndUpdate()
Turns on screen updating for the active document.
procedure GetCaretPos(var x, y: integer)
Returns the caret pos (x=column, y=line).
function getCurrentChar(): OleVariant
Returns the current character.
function GetNextChar(): OleVariant
Returns the next character. Note that this function (along with GetPreviousChar
) can be slow when used in long loops.
function GetPreviousChar(): OleVariant
Returns the previous character.
function GetTagAtCursor(wbSelect: WordBool): WideString;
Returns the tag in which the cursor is currently located in the editor. If a tag cannot be identified, the method returns an empty string.
If wbSelect is True, the tag will be selected (highlighted) in the document.
Example:
// Displays a message box with the current tag function Main() {
with (Application) {
MessageBox(ActiveDocument.GetTagAtCursor(false), 'Current Tag At Cursor', 0);
}
}
function GotoNextEndTag(wbSelect: WordBool): WordBool
Moves the next end tag, selecting it if wbSelect
is True. Returns False if no tag found.
function GotoNextStartTag(wbSelect: WordBool): WordBool
Moves the next starting tag, selecting it if wbSelect
is True. Returns False if no tag found.
function GotoPreviousEndTag(wbSelect: WordBool): WordBool
Moves the previous end tag, selecting it if wbSelect
is True. Returns False if no tag found.
function GotoPreviousStartTag(wbSelect: WordBool): WordBool
Moves the previous starting tag, selecting it if wbSelect
is True. Returns False if no tag found.
procedure Indent()
Indents the current selection.
procedure InsertTag(sStartTag, sEndTag: OleVariant; wbOverwriteSelection: WordBool)
Inserts the passed tag pair at the current cursor position, overwriting the selection if wbOverwriteSelection
is True. The cursor will be positioned between the start and end tags after this operation, and if wbOverwriteSelection
is False, the current selection will be surrounded by the tags.
procedure InsertText(InsertStr: OleVariant; wbOverwriteSelection: WordBool)
Inserts the passed string at the current cursor position, overwriting the selection if wbOverwriteSelection
is True.
function LastSavedDate()
Returns the datetime value for the last save of the active document file.
procedure Print(wbNoPrompt: WordBool)
Prints the active document. Prompts the user for print settings unless wbNoPrompt
is True.
procedure Redo()
Performs a single redo operation.
procedure Reload(wbPromptToSave: WordBool)
Reloads the active document, prompting to save changes if wbPromptToSave
is True.
function ReplaceAll(strSearch, strReplace: OleVariant; bMatchCase: WordBool): Integer
Replaces all occurrences of strSearch
with strReplace
, matching case if bMatchCase
is True. Returns the number of replacements made.
function Save: WordBool()
Saves changes to the active document, returning True if successful.
function SaveAs(wsFileName: widestring): WordBool
Saves changes to the active document to the file specified in the wsFileName
parameter, returning True if successful. If wsFileName
is empty, the standard "Save As" dialog box will be displayed to the user. Note that existing files will be overwritten by this function, so use with caution.
procedure SelectAll()
Selects all the text in the active document,
procedure SelectCurrentLine()
Highlights the current line.
procedure SelectLine(Index: Integer)
Highlights the passed line.
procedure SetCaretPos(x, y: Integer)
Sets the current column/line.
function TextPosToEditorPos(nPos:OleVariant):Wordbool
Converts an index in a text string in a script to the corresponding editor position, taking tabs and newlines, which count as two characters in the text but only as one in the editor, into account. For example, TextPosToEditorPos could be used by the Javascript charAt() function to determine the character at a specific editor position.
Note that here nPos is returned as an OleVariant but it's actual type is that of integer.
procedure Undo()
Performs a single undo operation.
procedure Unindent()
Unindents the current selection.
Use these methods to position the cursor. If wbSelect
is True, then the current selection will be extended to the new cursor position.
procedure CursorDocEnd(wbSelect: WordBool)
procedure CursorDocStart(wbSelect: WordBool)
procedure CursorDown(wbSelect: WordBool)
procedure CursorLeft(wbSelect: WordBool)
procedure CursorLineEnd(wbSelect: WordBool)
procedure CursorLineStart(wbSelect: WordBool)
procedure CursorPageDown(wbSelect: WordBool)
procedure CursorPageUp(wbSelect: WordBool)
procedure CursorRight(wbSelect: WordBool)
procedure CursorUp(wbSelect: WordBool)
procedure CursorWordLeft(wbSelect: WordBool)
procedure CursorWordRight(wbSelect: WordBool)