See Also: Set_Field_Value


To retrieve the value of a column in the current record of any database table.


Get_Field_Value {table-handle} {column-num} To {variable}

Argument Explanation

{table-handle} The number used to open the table.

iColumnNo The number of the column.

variable The variable that will hold the column value retrieved. Can be any simple data type or UChar[].

What It Does

Get_Field_Value moves a copy of the contents of a column into a program variable, variable, performing any type conversion necessary. The current record's value for the specified column will be retrieved.

The following example opens the Invt table, reads a record and shows the value for each column. This code runs in the order workspace.


Integer hTable       // Table handle to Invt

Integer iColumns     // Number of columns

Integer i            // To index through columns

String sName sValue  // Buffers for name and value of column


// Open table.

Open "Invt" As hTable

// Find first record in the table (by Recnum)

Vfind hTable 0 GT

Showln "Here is the data from record 1: "

// Get number of columns.

Get_Attribute DF_FILE_NUMBER_FIELDS Of hTable to iColumns


// Loop through columns printing name and value.

For i From 0 to iColumns

    // Get name.

    Get_Attribute DF_FIELD_NAME Of hTable i to sName

    // Get value.

    Get_Field_Value hTable i to sValue

    Showln "Column: " sName ". Value: " sValue



Working with UChar Arrays

The Get_Field_Value command can return a UChar array.  This can be used in place of a string variable and has the advantage that you don't have to worry about maximum string size and you don't have to concern yourself with embedded zeros.

If the return parameter is a UChar array it will move the table data to the array. The number of bytes copied will be the size of the array (SizeOfArray).

Procedure ReadFromTable

    UChar[] PDFManual

    Integer iSize


    Get_Field_Value Product.File_Number (RefTable(Product.PdfManual)) to PDFManual

    Move (SizeOfArray(PDFManual)) to iSize