Page 1 of 1

Asciioutout is overwriting the file,BUT i want it is once TI

Posted: Thu Sep 13, 2012 3:18 am
by svchowdary83
I have one ASCIIOUTPUT under the prolog tab and as soon as TI excutes asciioutout is overwriting the file.BUT i want it is once TI excutes i have to add the new data into the existed txt file.is it possible? If possible how

Re: Asciioutout is overwriting the file,BUT i want it is onc

Posted: Thu Sep 13, 2012 3:24 am
by Alan Kirk
svchowdary83 wrote:I have one ASCIIOUTPUT under the prolog tab and as soon as TI excutes asciioutout is overwriting the file.BUT i want it is once TI excutes i have to add the new data into the existed txt file.is it possible? If possible how
This is a not uncommon request, since it's a function which would actually be useful. However IBM is too busy building unwieldily, monolithic Java applications with pretty chrome trimmings to concern itself with such mundane pursuits. The easiest way to achieve this is the method mentioned in Mike Cowie's post in this thread.

Re: Asciioutout is overwriting the file,BUT i want it is onc

Posted: Thu Sep 13, 2012 12:21 pm
by tomok
The method I use to do this is to move the actual ASCIIOUTPUT statement you have in the Prolog tab into the Data tab, add a variable counter, and then encapsulate that single statement inside an IF that only executes for the first record. You can still leave all the code that generates the output in the Prolog, just actually write the result in Data. Like this:

Prolog

Code: Select all

StringtoOutput = WhateverCodeYouAreUsing;
NumRecs = 0;
Data

Code: Select all

IF(NumRecs < 1);
  ASCIIOUTPUT(FileName, StringtoOutput);
ENDIF;

Rest of Data tab code
........
NumRecs = NumRecs + 1;