DFRGTxt function

Official Content
This documentation is valid for:

Reads a character type field of the current line (read by dfrnext).


DFRGTxt( Text [ , Length ] )


    It can be an attribute or variable or character or varchar type. The read value will be stored here.
    It can be an attribute, variable or constant of numeric type, optional,  indicating the maximum number of characters to be read.  Their value, if specified, may not exceed the size defined for <txt>. In case it is omitted, it is assumed as the size defined for the attribute or variable  <txt>. If this parameter exceeds the <txt> size, results become unpredictable.

Note: If the parameter encoding was specified in the function DFROpen, this length means “number of bytes”.

Type Returned:


Objects: Procedure, Transaction, Web PanelData Provider
Generators:  .NET, , .NET Framework, Java, Ruby (up to GeneXus X Evolution 3)


This function may return some of the following values:

Value Result Description
0 Successful operation. The field has been read.
-1 Wrong sequence. It occurs when this function is called before calling the dfrnext function, or when the last call to dfrnext returned a value other than zero (error). If the trace is enabled you will see the ADF0004 or ADF0006 message.
-5 Wrong format. The string in the field does not have the correct format. This is mostly because the field you are trying to read is of a different type (number, date, etc.) If the trace is enabled you will see the ADF0009 message.
-6 Overflow. This is a warning indicating that the string length in the record is greater than the maximum specified (or assumed) in the <length> parameter. The value read is cut to <length> characters.


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"

See Also

Delimited ASCII files functions