Controlling the Listener Contents and the Insertion Point

The Listener output pane’s content and insertion point placement can be controlled with the following methods:

clearListener()

Clears all text from the Listener output pane.

setListenerSel #(<start_integer>,<end_integer>)

Sets the current text selection in Listener. The start and end values are the character offsets in the Listener output pane text, starting at 0. If the start and end values are the same, no text is selected and the insertion point is placed at the specified point. You can specify -1 for the start or end values, which specifies the end of the Listener output pane text.

For example,

the following would put the insertion point at the end of the text:

setListenerSel #(-1,-1)

while the following would select all of the text in the Listener output pane text:

setListenerSel #(0,-1)

<start_integer> and <end_integer> are integer literals, or expressions that evaluate to an integer.

getListenerSel()

Returns the current text selection indexes as a two-element array, #(start, end). These values are the character offsets in the Listener output pane text, starting at 0. If there is no selection, but only an insertion point, the start and end values are equal. Only the selections set using the setListenerSel() method are recognized by this method. If no selection has been set using the setListenerSel() method, the start and end values returned are the offset to the end of the Listener output pane text.

getListenerSelText()

Returns the currently selected text, or an empty string if no text is selected and only the insertion point is showing. Only the selections set using the setListenerSel() method are recognized by this method. If no selection has been set using the setListenerSel() method, an empty string is returned.

For example,

the following lines would capture the entire contents of the Listener output pane to variable ListenerText:

( global ListenerText -- declare variable so its scope is higher

-- than inside just the following block

-- expression

( setListenerSel #(0,-1) -- select all the text

ListenerText=getListenerSelText() -- get selected text

setListenerSel #(-1,-1) -- set insertion point at

-- end of output pane

)

)

setListenerSelText <replacement_string>

Replaces the currently selected text with the replacement string. If no text is selected and only the insertion point is showing, setListenerSelText() inserts the replacement string at the insertion point. Only the selections set using the setListenerSel() method are recognized by this method. If no selection has been set using the setListenerSel() method, the insertion point is the end of the Listener output pane text. <replacement_string> is a string literal or an expression that evaluates to a string.

include <filename_string>

Inserts the specified file’s content into the Listener output pane. The inserted text is not evaluated. You can use this method to load a script and then step through it, executing any selected text with SHIFT+ENTER. <filename_string> is a string literal or an expression that evaluates to a string, and specifies the name of the file to insert.

Example uses are:

include "my_script.ms"

or

scriptfile="c:\\my_scripts\\my_script.ms"

include scriptfile

If you don’t explicitly specify a directory in the file name, the file will be searched for in the following directories, in the order listed: