Page 1 of 1

Rouitne to create the file in appending mode

Posted: Thu Sep 03, 2009 5:29 am
by Aquilis
Hello,
I have created a transform routine as shown below. It actually restructures the incoming data and creates the file & writes the data in append mode. Routines is behaving as I am exepcting but the issue with this I have to touch the files first (I have to get the zero byte first file created).

What I'm a expecting is , Routine it self should create the file & write the data in appending mode to it.

Since I am getting the 'N' number of files with different set metadata defined in the them, I am following this approach.


Code: Select all


 FileDir= '/Wrkdir/data'
      FileName="xxx_unspecified.dat"
      ColCnt=count(ColName,",")+1
      IF Rownum>0 Then
*** Write To File
         PathName = FileDir:'/':FileName
         OpenSeq PathName To FileVar Then
            SEEK FileVar,4,2 
            ELSE
               Call DSLogWarn("Error in SEEK", RoutineName)
            END
            For i=1 to ColCnt
               Column_Name=Field(ColName,',',i)
               Column_Value=Field(ColValue,',',i)
               FileFormat=File:'|':i:'|':Column_Name:'|':Column_Value:'|':Rownum
               WRITESEQ FileFormat TO FileVar Then
               END
            NEXT i
         END
         Ans=FileFormat
         weofseq FileVar
         CloseSeq FileVar
      End
 
Could anybody of you help me on this.
Thank you,

Posted: Thu Sep 03, 2009 5:32 am
by chulett
Check the OpenSeq syntax in the BASIC manual, you need to add the 'else' path to create it when the open fails. A search here would turn up examples as well.

Posted: Thu Sep 03, 2009 3:03 pm
by ray.wurlod
... and, within the ELSE path of the OPENSEQ statement, you can use a CREATE statement to force the file to exist.

Posted: Fri Sep 25, 2009 7:11 am
by Aquilis
Thanks Ray,
It's working.