Objects: Procedures, Transactions, Web Panels
Languages: .NET, Java, Ruby
To open a text file for its processing. It is the first function to be called to begin reading a text file.
DFROpen(FileName [ , length [ , fdel [ , sdel [ , encoding ] ] ] ] )
It can be an attribute, variable or constant of the char type. Its value will be considered as the file name to be processed. It may contain directory specifications or not. If it doesn’t, it will be searched in the current directory.
It can be an attribute, variable or constant of the numeric type, optional, which indicates the maximum size, in number of characters, of the record to be read. See that the delimited ASCII files have records (lines) of variable length. If it is specified, the value should correspond to the maximum quantity of characters that a line may have. The default value is 1024.
It can be an attribute, variable or constant of the character type, optional, which indicates the delimiting character among fields. If you wish to specify the tab character as separator, the value of this parameter must be the string “\t”.
It can be an attribute, variable or constant of the character type, optional, which indicates the delimiting character of the string fields. Only the first character of the parameter value is considered. Its value may be any character not apperaing in the texts. Its default value is the “ (quotation mark).
It can be an attribute, variable or constant of the character type, optional, which indicates the encoding to be used to read the file. If you specify this parameter, it means that the length used in the function DFRGTxt means “number of bytes”.
This function may return some of the following values:
0: Successful operation. The file has been opened.
-1: Wrong sequence. It occurs when this function is called more than once without previously calling the dfwclose function. If the trace is activated you will see the ADF0005 message indicating this error.
-2: Opening error. It occurs when the file identified as <filename> could not be opened. The cause may be clearly identified by enabling the trace and looking for the message with ADF0001 code. It is most common that the file does not exist.
-8: Not enough memory. It occurs when it isn’t possible to reserve a buffer of <length> bytes. If the trace is activated, you will see the ADF0007 message indicating this error.
For this example, the parameter field separator is not required.
&Text = ""
&i = dfropen( "Test.txt",1024,,"")
If &I = 0
Do while dfrnext( ) = 0
&i = dfrgtxt(&Linetxt) // The length of the line is given by the size of the variable.
&Text = &Text + Newline() + &Linetxt
&i = dfrclose( )
&Texto = "Could not open file"
Delimited ASCII files functions