Planning Analytics

 View Only

You cannot append to a file when using AsciiOutput and TextOutput, right? Wrong!

By George Tonkin posted Tue April 04, 2023 01:38 AM


You cannot append to a file when using AsciiOutput and TextOutput, right? Wrong!

Often times developers need to append to an existing file to add additional out e.g. a report with headers, a report total, a debug log or an audit trail of sorts.

This has typically required some additional coding whether testing for the first record to write out a header or testing to see if you are on the last record to write out a total.

Similarly, when calling multiple child processes that each produce content needed in one file, the developer would need to get creative around stitching files together using command line or powershell commands.

What if I told you that there is an easier way that has been around since the first release of V11 circa 2017 but has thus far been undocumented and hidden as one of IBM’s best kept secrets?

The missing piece of the puzzle is the AsciiOutputOpen() function. The function has the following syntax:


A zero seems to indicate that the file should be truncated first.

A one indicates that the file should be appended to.

Alternatively you could also use the syntax:


A sample TI process using my Period dimensions as a datasource shows how this “new” command is used:

#Section Prolog


#--Start with a blank file - truncate if it exists


Asciioutput(sFilename, 'Prolog', 'Start');

#Section Metadata


Asciioutput(sFilename, 'Metadata', vPeriod);

#Section Data


Asciioutput(sFilename, 'Data', vPeriod);

#Section Epilog


Asciioutput(sFilename, 'Epilog', 'End');

Upon completion of the execution I have a file called george.txt in my data directory with the following:

This was only one example but illustrates how simple this process should have always been and now it is. As stated above, this seems to apply to both AsciiOutput and TextOutput.

As always with undocumented features, no warranties etc. etc. but would be good if we could all raise awareness to get this command into the mainstream on V11, supported in PAW and documented for all to be aware of and use.

Would be good to have your feedback and comments around this.




Wed June 21, 2023 02:41 AM

Great Find

Thu June 15, 2023 11:21 AM

Really useful, thanks :)

Thu April 06, 2023 03:15 AM


Time to go amend some processes. :-)

Wed April 05, 2023 07:49 AM

This is just great :-), I had no idea. Thanks.