Blitz3D+ Command Reference

SetTextAreaText textarea,text$[,pos][,len][,units]

Parameters

textarea - text area gadget

text$ - replacement text

pos (optional) - start of the range to replace; 0 (default)

len (optional) - length of the range to replace; -1 replaces through to the end (default)

units (optional) - what pos and len count:
1: characters (default)
2: lines

Description

Replaces all or part of the text in a text area.

Requires Extended language mode.

With just the first two arguments it replaces everything - loading a file into an editor pane. Adding a range turns it into surgery: replace one line in line units, or a marked span in character units. Ranges that reach outside the text are clamped rather than failing.

Positions count whole Unicode characters, not bytes, so a range can never cut an emoji or accented character in half. Line breaks inside the area are single carriage returns (Chr$(13)).

Programmatic edits are quiet and tidy: the user's cursor and selection are preserved around the change, and no $401 gadget-action event is posted (user typing does post one). This works on a locked (read-only) text area too. To append to the end - the log-window pattern - AddTextAreaText is simpler and moves the caret for you.

See also: TextAreaText, AddTextAreaText, FormatTextAreaText, TextAreaLen, LockTextArea.

Index