UserGuide

IDE Scripting String Commands

From Xojo Documentation

These are general String-related commands that are useful when used with the other IDE Scripting commands.

Clipboard As String

Used to get or set the text contents of the OS clipboard.

Sample Code

Create a new Note for the selected project item and pastes in the contents of the Clipboard into the Note:

DoCommand("NewNote")
Text = Clipboard

EndOfLine As String (read-only)

Returns the default line ending for the OS running the IDE. This is also the line separator used for code editor text that is returned by Text and SelText.

Sample Code

Add text to a new note:

DoCommand("NewNote")
Text = "Line1" + EndOfLine + "Line2"

SelLength As Integer

Gets or sets the length of characters in the current selection of the code editor.

SelectionLength As Integer (New in 2019r2)

Gets or sets the length of characters in the current selection of the code editor.

SelStart As Integer

Gets or sets the offset of the selection (or insertion) point in the code editor.

SelectionStart As Integer (New in 2019r2)

Gets or sets the offset of the selection (or insertion) point in the code editor.

SelText As String

Gets or sets the selected text in the code editor. After assign a string to SelText, the selection will be empty and positioned immediately after the inserted text.

SelectedText As String (New in 2019r2)

Gets or sets the selected text in the code editor. After assign a string to SelText, the selection will be empty and positioned immediately after the inserted text.

Sample Code

Take the selected text and add an inline constant containing the text to the top of the method and replaces the selected text with the name of the constant:

Var constantText As String
constantText = SelText

Var newConstant As String
newConstant = "Const kValue = """ + constantText + """"

SelStart = SelStart-1
SelLength = SelLength + 2
SelText = "kValue"

Text = newConstant + EndOfLine + EndOfLine + Text