text

Format messages as a text file

Description

text collects and formats incoming messages as text which can then be output as single lines of text.

Arguments

Name Type Opt Description
filename symbol Names a text file to be read in when the object is loaded.

Messages

int input [int]
Stores the integer within text.
float input [float]
Stores the float within text.
list input [list]
Stores the list within text.
anything input [list]
The message is stored in the text object, placed after any previously stored messages, and is followed by a space.
clear Erases the contents of text.
cr Puts a carriage return at the end of the contents of text, to start a new line. If the last character in text is a space, the carriage return replaces that space.
(mouse) Double-clicking with the mouse on the text object (when the patcher window is locked) opens an editing window in which the contents of text can be viewed and edited. The text object ignores messages to change its text while the editing window is open. Unlike the capture object, changes made in the editing window of text actually alter the contents of the object.
dump The word dump causes text to send its contents out of the object's left outlet.
editwith text-editor [symbol]
The word editwith, followed by a symbol that specifies a text editor, will open the file for editing using the specified editor.
filetype filetype-code (four letters) [symbol]
The word filetype, followed by a symbol, sets the file types which can be read and written into the text object. File types are specified using the standard four-letter type code combination (e.g. filetype ffoo). The message filetype with no arguments restores the default file behavior -- either Max binary or text file formats. File types are mapped to filename extensions on Windows based on the messages to max contained in the file max-fileformats.txt in the init folder, which is loaded on startup. If you are defining your own filetype, you may want to include your own text file in the init folder in order to specify a mapping between an extension and your four-letter type code.
line index [int]
The word line, followed by a number, causes text to send out the contents of that line number (up to 256 characters) with the word set prepended (for setting the contents of a message box). Lines are numbered beginning with 1; any line number message less than 1 is converted to line 1. If a nonexistent line number is requested, nothing is sent out.
open Opens the object's text window for editing. Double-clicking on the text object in a locked patcher has the same effect. The text object ignores messages to change its text while the editing window is open. Unlike the capture object, changes made in the editing window of text actually alter the contents of the object.
read filename [symbol]
The word read, followed by a symbol that specifies a filename, will read the contents of a text file. If no filename or pathname is specified, the read message will call up the standard Open Document dialog box, so that a text file can be specified. Use the filetype message to use a custom filetype with this object.
query The word query sends a number that specifies the number of lines stored in the text object out the object's right outlet.
t_symbol input [symbol]
Stores the symbol within text.
tab Puts a tab stop at the end of the contents of text. If the last character in text is a space, the tab stop replaces that space.
settitle window-name [symbol]
The word settitle, followed by any word, sets the title of the text window. If you want more than one word to appear as the default text, you must enclose the words in double quotes or precede the spaces with a backslash (\).
symbol any symbol [symbol]
The word symbol, followed by any word, stores that word at the end of the contents of text. This is useful if you want to store a word that would otherwise be understood as a specific message by text. For example, symbol clear stores the word clear, followed by a space, at the end of the contents of text, rather than erasing the contents.
wclose Closes the window associated with the text object.
write filename [symbol]
The word write, followed by a symbol that specifies a filename, will save the contents of text as a text file in the current default folder unless the file is specified with an absolute pathname. If no filename or pathname is specified, the write message will open up a standard Save As dialog box, so that the contents of text can be saved in a separate text file. Use the filetype message to use a custom filetype with this object.

Information for box attributes common to all objects

Output

bang: Out middle outlet: When a file has finished loading in response to a read message, a bang is sent out the middle outlet.
int: Out right outlet: In response to a query message, a number corresponding to the number of lines of text stored in the text object is sent out the right outlet.
symbol: Out left outlet: When a line message is received, the text of the specified line number is sent out preceded by the word set. The message can be used to set the contents of a message box (or can be sent to any other object for which that particular set message is appropriate).

Examples

Collect messages as text to paste elsewhere or to save as a separate file

See Also

Name Description
capture Store numbers to view or edit
filein Read in a file of binary data
itable A table in a patcher window
spell Convert input to ASCII codes
sprintf Format a message of words and numbers
table Store and graphically edit an array of numbers
textedit User-entered text in a patcher