put_in_text_file2

The function put_in_text_file2 writes produced text to a file. The text saved in this way will not appear in the result document. You can use this function several times in a model. Each time you do this the text produced up to the call is placed in the file.

This function produces a plain text document regardless of the word processor the model document has been made with. The plain text document will be encoded using the character set encoding specified in the parameter "encoding". If the document content cannot be represented using the specified character set encoding, an error is generated. Unlike the put_in_text_file function, the put_in_text_file2 function does not support include document processing.

put_in_text_file2 ( "textfile_to_be_produced" ; 
"path/folder_of_the_text_file" ;
"overwrite Y/N" ;
"encoding" )

The function put_in_text_file2 requires four parameters:

  1. "textfile_to_be_produced" is of the type TEXT. The name of the document.
  2. "path/folder_of_the_text_file" is of the type TEXT. The path and name of the folder or folder in which the text file will be written.
  3. "overwrite" is of the type TEXT, Y or N. When you set this parameter to Y an already existing file is overwritten, when you set this parameter to N the end user will be prompted to specify an alternative filename and folder.
    Note
    This will cause problems in an ITP/Server environment since ITP/Server cannot interact with the end user.
  4. "encoding" is of the type TEXT. The value must be one of the following; UTF-8, UTF-16, ISO-8859-1, ISO-8859-15 and 1252. This parameter specifies the character set encoding of the plain text document that is to be written.

The put_in_text_file2 function writes the ITP output to a text file, and not a copy. Once it is written to a file the output is no longer available for the ITP model and it will not appear in the result document. The reason for this is that ITP stores text that is produced in an internal buffer. When you call the put_in_text_file2 function ITP writes the content of the buffer to the file, this clears the internal buffer.

If you want to create multiple files from one output you can use the open buffer mechanism.

Documents that ITP produces through the put_in_text_file2( ) function are directly available for opening after ITP successfully executed this function.

Note

The plain text result document will also contain word processor instructions such as text-boxes, fields and footnotes. This might produce unexpected results, because ITP makes no attempt to maintain the layout of the output document. Therefore we advise you to avoid the use of word processor instructions that will appear in result documents when the put_in_text_file2 function is used.

Example

#
This line will be stored in the file 'file.txt' on c:\temp, and will not appear in the result document.
#
TEXT doc := put_in_text_file2("file.txt"; "c:\temp"; "Y"; "ISO-8859-1")
#
The file produced is @(doc).
These lines will appear in the result document because they are produced after the put_in_text_file2 call above.
#