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.

In versions prior to 3ds Max 2014, this function was unusable because it would return OK and thus destroy the newly set selection with its own return value.

In principle, every MAXScript function must return a value, but this is a very good case for an exception.

Starting with 3ds Max 2014, this function will not return anything and actually select the text in the Listener!

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 to capture the Listener to
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 USAGES 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:

See Also