Page 1 of 1

How to create a new file using WriteSeq

Posted: Tue Jan 14, 2003 12:39 am
by sankar18
Hi,

How create a new file using WriteSeq. or using other statement.
Is there any other approach to create a file in routine.

with regards,
T Sankar

Posted: Tue Jan 14, 2003 1:52 am
by ray.wurlod
OpenSeq opens a channel to the I/O system.
It is possible, therefore, to "open a file for writing" even though the file does not yet exist. In this case, the ELSE clause of the OpenSeq statement is executed, and the STATUS() function returns 0.
If the channel is closed (CloseSeq) without any form of Write statement (that is, WeofSeq, WriteSeq or WriteBlk) having been performed, the file will still not exist.
If the channel is closed and any form of Write statement has been executed, then the file will exist (provided permissions, etc., allow it).
If you want to guarantee the creation of a zero length file, even though you end up writing nothing to it, you can simply write an end of file mark (WeofSeq). Another way is to use the CREATE statement inside the ELSE clause of the OpenSeq statement.
You can find all of these statements in the BASIC manual.
Alternately, prior to opening the file, you can use the touch command at the operating system level to create it. This command exists for all UNIX platforms, and ships with DataStage (as touch.exe) for Windows platforms.


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518