Xbasic

FIELD.VALUE_GET Function

Syntax

Field_Value as A = Value_Get([N clipboard_format])

Field_Value as A = . Field_Name.VALUE_GET( [ Clipboard_Format as N ] )

Arguments

Field_Name

The name of a field in the table.

clipboard_format

Optional. Specifies the format of the data that is being returned. For example, if you wanted to read a bitmap into a blob variable, you would specify CLIPBOARD_DIB as the Clipboard Format. See the "Constants" section in the Xbasic Explorer for a list of Clipboard Formats.

CLIPBOARD_DIB
CLIPBOARD_DIF
CLIPBOARD_SYLK
CLIPBOARD_TEXT
CLIPBOARD_TIFF

Description

Gets the field contents. Clipboard format is optional format of data.

Discussion

The .VALUE_GET() method returns the value of a field referenced by the object pointer. The type of Field_Value returned depends on the field's type. Character and memo fields return character strings; date, numeric, and logical fields return values in their corresponding field types. The types of fields that support this method are:

Check boxes
Combo boxes
List boxes
Memo controls
Radio buttons
Tree Controls
Type-In (text) controls

Note : For Rich Text Memo fields use RTF_FIELD_TO_TEXT(). To determine which data type is returned, use the <FIELD>.TYPE_GET() method. Alpha Anywhere provides other, more direct, ways of getting a field value if you know the field name, and the alias name of the table, or if you have an object pointer reference to the table. If you know the table alias name:

aliasname->fieldname, e.g. customer->lastname

If you have an object pointer reference to the table:

.fieldname, e.g., tbl_1.lastname

For example, these statements are all equivalent:

dim tbl as P
tbl = table.current()
fld = tbl.field_get("lastname")
name = customer->last_name
name = tbl.lastname
name = fld.value_get()

Example 

Use VALUE_GET()when you don't know the field name. This script prints the contents of each record in the Trace window.

dim tbl as P
dim fld as P
tbl = table.current()
number_of_fields = tbl.fields_get()
tbl.fetch_first()
while .NOT. tbl.fetch_eof()
    for i = 1 TO number_of_fields
        fld = tbl.field_get(i)
        field_type = fld.type_get()
        select
            case field_type = "N"
                trace.writeln( str( fld.value_get() ) )
            case field_type = "D"
                trace.writeln( dtoc( fld.value_get() ) )
            case field_type = "L"
                trace.writeln( iif(fld.value_get(), "T","F") )
            case else
                trace.writeln( fld.value_get() )
        end select
    next i
    trace.writeln("----------------------------")
    tbl.fetch_next()
end while

This example returns the value of a text memo field.

dim fld as P
dim tbl as P
dim txt as C
tbl = table.current()
fld = tbl.field_get("Mymemo")
txt = fld.value_get()
ui_msg_box("Text Memo Contents", txt)

See Also