Recherche Google
OpenMusic 6 – User ManualOM Objects > OM Basic Objects > Text File Tools > TextFile Box
previous pagenext page

TextFile Box

The textfile box represents a text buffer in a visual program. It can be

  • internal to a patch – by default
  • attached to an external file of the computer.

Textfile boxes are accessed via the Classes / Basic Tools / Text File I-O / TEXTFILE menu.

Editing a Text via the Editor

The textfile box has a basic editor where texts can be edited or modified.

Double click on the box to open the editor.

Inputs and Outputs

The textfile object has four inputs and outputs :

  1. "self" : the object itself

  2. "exp-list" : a textual content

  3. "eval-mode" : text presentation format, that is, a text, a data list or a list.

  4. "ed-mode" : edition mode, that is, the way contents are added in the file.

Exp-List : Contents

The " exp-list " input and output represent a textual content. The "exp-list" input accepts :

  • single items – strings, numbers, etc.
  • lists, whose each item represents a new line in the textfile .

It allows to set or read the contents of the textfile box within visual programs. The implementation and interpretation of the content depends on the "eval-mode" and "ed-mode" inputs settings.

Inputting contents with "exp-list".
Inputting contents with "exp-list".
Ed-Mode : Writing at Successive Evaluations

The "ed-mode" input determines the way input data is written in the text file with successive evaluations.

It offers two options :

  1. "supersede" : any previous contents is overwritten by new input data.

  2. "append" : new input data is append after the existing contents.

    Hence, the results of several successive iterations can be stored in the text buffer.

Click on the input to select an option.

Left, "supersede" : each evaluation reinitializes the TextFile contents. Right, "append" : the previous contents is kept in the TextFile.
Left, "supersede" : each evaluation reinitializes the TextFile contents. Right, "append" : the previous contents is kept in the TextFile.
Eval-Mode : Writing Format

The "eval-mode" input determines the format of the contents returned by "exp-list".

Three formats are available :

  1. "text" : returns a list of strings corresponding to the successive lines of the text.

  2. "data list"  : returns a list of the items matching each line of the text buffer, interpreted as "raw" data .

    For instance, numbers are returned as plain numbers lists, (1 2 3)... instead of strings lists  ("1 2 3").

    Several items on a line are gathers in the same list.

  3. "list" : returns an elementary list ignoring line returns.

Three options for formatting the text contents with "eval-mode". The result appears when evaluating the "exp-list" output.
Three options for formatting the text contents with "eval-mode". The result appears when evaluating the "exp-list" output.

Outer Environment

Importing / Exporting Contents

The contents of textfile can be imported or exported from / to a real file on the disk.

To import or export a contents :

  1. Ctrl / right click on the textfile box

  2. choose Import Contents from File or Export contents to File in the contextual menu

  3. choose a file and directory in the dialogue window.

The imported file appears in the textfile box and in the buffer.

Text Format

The extension of the exported instance must be added by the user.

Attachment to External Files

Other options allow to attach the object permanently to an external file on the disk .

  • To fill textfile with the contents of a persistent file, select Import and Attach File .
  • To save the contents of textfile in an external file, select Export and Attach File.

These option are alike "Import" and "Export" options, but the link the content of the object with a file on the hard drive of the computer.

In the dialogue window, choose a name and a directory for the new file.

  • To remove a link with an attached file, select Free Attached File. This option is only available if the textfile is already attached to a file.

    Once the attached file is is "freed", contents of the textfile is internalized in the patch.

Inputting data via "exp-list" on append mode.
Inputting data via "exp-list" on append mode.

To modify an attached file :

  • input data via the "exp-list" input.
  • use the text editor, and press cmd + s to store the modifications in the box.

Saving the object implies that the related file on the hard drive is modified as well.

Externalizing Contents
The attached file has been deleted. The Listener displays an error message.
The attached file has been deleted. The Listener displays an error message.

Contrary to the import and export options, the attach option implies that the textfile object itself refers to a persistent file. Hence, its content won't be stored int the patch itself.

  • Parallel modifications of the attached file will affect the textfile box's content.

  • If the attached file is deleted of moved, it won't be found when reloading the patch. The textfile is then empty.

Inputting and Outputting Files

Initialization

To initialize a textfile with a file :

  1. enter the name of a file in the "self" input of an infile , outfile or tempfile box

  2. connect the output of the box to the "self" input of the textfile box.

The textfile is then attached to the corresponding file.

Connecting a pathname to TextFile
Connecting a pathname to TextFile
Returning Pathnames

A textfile box can also be convenient to visualize the results returned by boxes that return pathnames. The corresponding file must be created previously.

The editsco function from the OM2Csound userlibrary writes a text file – a Csound score – and returns the file pathname.
The editsco function from the OM2Csound userlibrary writes a text file – a Csound score – and returns the file pathname.
previous pagenext page
About...(c) Ircam - Centre PompidouMade with Scenari