Share via


TextIo.read Method

Definition

Reads the next full record from a TextIO object.

public:
 override cli::array <System::Object ^> ^ read();
public override object[] read ();
override this.read : unit -> obj[]
Public Overrides Function read () As Object()

Returns

Object[]

A container that holds one record.

Remarks

Each entry in the container equals one field in the record. The definition of the next full record is controlled by the inFieldDelimiter, inRecordDelimiter, and inRecordLength properties. These properties have default values that allow input and output of the most common formats. It might be necessary to adjust the properties by using the inFieldDelimiter, inRecordDelimiter, and inRecordLength methods.

The following example reads a record from a file and uses the conpeek function to extract values from the record.

public void run() 
{ 
    container         fileRecord; 
    IntrastatToProdCom intrastatToProdCom; 
    if (filename) 
    { 
        this.initializeFile(); 
        fileRecord = prodComFile.read(); 
        ttsbegin; 
        while (fileRecord) 
        { 
            intrastatToProdCom.IntrastatItemCodeID = conpeek(fileRecord, 1); 
            intrastatToProdCom.InventProdComCodeID = conpeek (fileRecord, 2); 
            intrastatToProdCom.ValidFromYear = conpeek (fileRecord, 3); 
            intrastatToProdCom.ValidTillYear = conpeek (fileRecord, 4); 
            intrastatToProdCom.insert(); 
            filerecord = prodComFile.read(); 
        } 
        ttscommit; 
    } 
}

Applies to