add_to_output

The add_to_output function puts output in a document. Multiple calls to add_to_output( ) are concatenated into one output document.

add_to_output ( "outputdocument_to_be_produced"; 
                "path_folder_of_the_output_document";
                "Overwrite Y/N"; "pagination (ignored)";
                "process_includes Y/N" ) 

The result of this function is of type TEXT, it is the path and name of the document produced. A TXT template produces a TXT file; a Microsoft Word template produces a Microsoft Word document.

This function has no effect on the AiaDocXML and HTML output.

add_to_output has five input parameters of type TEXT:

  • outputdocument_to_be_produced, type TEXT. This is the name of the produced document.
  • path_folder_of_the_output_document, type TEXT. The path and name of the folder or a folder that the output document is written to.
  • overwrite, Y or N, type TEXT. When you set this parameter to Y, the existing document is overridden; when you set this parameter to N, the end user is prompted to specify an alternative file name or folder. Interactivity is not possible in a KCM Core environment.
  • pagination, type TEXT. The value of this parameter is ignored.
  • process_includes, Y or N, type TEXT. Resolve __INC post-includes in the result document. When you have enabled the check box Process includes on the Run tab of KCM Core Administrator, KCM always resolves post-includes.

The add_to_output( ) function writes the KCM output to a text file and does not create a copy. Once written to a file, the output is no longer available for a Template script and it does not appear in the result document. The reason for this is that KCM stores produced text in an internal buffer. When you call the put_in_text function, KCM writes the content of the buffer to the file, which clears the internal buffer.

To create multiple files from one output, you can use the open_buffer mechanism (see open_buffer).

Documents that KCM produces through the add_to_output( ) function are directly available for opening after KCM successfully executes the put_in_text_file2( ) function.

An example is provided here.

TEXT outputdocument_to_be_produced := "output.doc"                                      

TEXT path_folder_of_the_output_document := "c:\temp\" 
#
This is the first part of the result document that will be put in the output document.
#
TEXT doc := add_to_output(outputdocument_to_be_produced;                          path_folder_of_the_output_document; "Y"; "N"; "N")
#
This is the text that is produced after the first function call. It will also be placed in the output document by the next function call.
#
ASSIGN doc := add_to_output(outputdocument_to_be_produced;                           path_folder_of_the_output_document; "Y"; "N"; "N")

#
The file produced is @(doc).
#

If you call the function add_to_output( ) in a Microsoft Word DOCX model, you should be aware that the final output document must end with a paragraph ending.