Sets/queries the text cursor position, the selection, and optionally replaces/deletes the original text inside of the selection.

Synopsis

cursorpos = EditSelect(start, end, replace, options)

Args

start is the line number and character number upon that line where the selection starts. Each is separated by a space. For example, '1 1' sets the selection to start at the first character on the first line (ie, the start of the script).

end is 1 the line number and character number upon that line where the selection ends. Each is separated by a space. For example, '2 4' sets the selection to end at the fourth character on the second line.

replace is the name of the REXX variable in your script that is initialized to the desired lines to insert over the selection. The variable with a tail name of 0 is a count of how many lines to insert. The variable with a tail name of 1 is the first line, a tail name of 2 is the second line, etc.

option is any of the following:

'CLIP' The replacement text is gotten from the windows clipboard. replace can be omitted.
'TEXT' 'replace' is not a variable name, but instead is the actual text to insert.

If you pass no args, then the text cursor's position, nor the selection are changed. This is handy if you wish only to query the cursor's current position.

If character number is -1, the cursor is set to the end of the line.

Returns

The text cursor's new position, or an empty string if an error. The text cursor will be set as follows:

If you replace text, it will be set to the end of the replacement. If you delete text, it will be set to 'start'. If you neither replace nor delete text, it will be set to 'end'.

Notes

To set the selection to encompass the entire contents of a window, set the start to '1 1' and the end to '-1 -1'.

To remove the selection, and set the text cursor position, pass the same start and end positions. For example, passing a 'start' and 'end' of '1 1' set the text cursor at the first character of line 1 (ie, the start of the script). Passing '-1 -1' for both 'start' and 'end' sets the cursor to the end of the script. Passing '1 -1' sets the cursor to the end of line 1. Etc.

If you replace/delete the selected text, then there is no selection remaining.