DTWF_OPEN

AIX HP-UX Linux OS/2 OS/390 OS/400 PTX SUN Win NT
X X X X X X X X X

Purpose

Opens a text file.

Format

@DTWF_OPEN(filename, mode, retry)

@DTWF_OPEN(filename, mode)

Parameters

Table 176. DTWF_OPEN Parameters
Data Type Parameter Use Description
string filename INOUT The name of the file to open. On successful completion of the call, this parameter returns the fully qualified file name.
string mode IN The type of access requested:
  • r - opens an existing file for reading.
  • w - creates a file for writing. (Destroys existing file of same name, if it exists.)
  • a - opens a file for appending. Net.Data creates the file if it is not found.
  • r+ - opens an existing file for reading and writing.
  • w+ - creates a file for reading and writing. (Destroys existing file of same name, if it exists.)
  • a+ - opens a file in append mode for reading or appending. Net.Data creates the file if it is not found.
integer retry IN The number of times to retry if the file cannot be opened immediately. The default is not to retry.

Return Codes

Table 177. DTWF_OPEN Return Codes
Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1002 An input parameter contained a string value which consisted of the null-terminating character.
1003 An incorrect number of parameters were passed on a function call.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.
2000 A flat file interface built-in function could not find the specified file.
2001 A flat file interface built-in function could not open the specified file because it was in use by this or another process, and could not be shared in the specified mode.

Usage Notes

  1. When the file does not exist, an absolute path for the filename should be specified, and the directory where the file is to be created must match a directory specified in FFI_PATH. If an absolute path is not used, the file will be opened in the current working directory.
  2. DTWF_OPEN keeps the file open, otherwise, the file is closed after each flat file operation.
  3. Use DTWF_OPEN to reduce the number of times a file is open. If DTWF_OPEN is not used, the file is closed after each flat file operation. The file is left open until it is closed using DTWF_CLOSE or macro processing ends.

Examples

Example 1:

%DEFINE {
  myFile = "c:/private/myfile"
  myMode = "r+"
%}
@DTWF_OPEN(myFile, myMode, "1000")


[ Top of Page | Previous Page | Next Page | Index ]