Opens 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”. The default value is "," (comma).
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 appearing in the texts. Thedefault value is “ (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”.
Objects: Procedure, Transaction, Web Panel, Data Provider
Generators: .NET, .NET Framework, Java, Ruby (up to GeneXus X Evolution 3)
This function may return some of the following values:
||The file has been opened.
||It occurs when this function is called more than once without previously calling the dfrclose function. If the trace is activated you will see the ADF0005 message indicating this 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.
||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( )
&Text = "Could not open file"
Delimited ASCII files functions