Xbasic

FIELD.VALUE_PUT Function

Syntax

V Value_Put(A Value[,N clipboard_format])

Arguments

Value

The data to put into the field.

clipboard_format

Optional. Specifies type of data in the clipboard

CLIPBOARD_DIB
CLIPBOARD_DIF
CLIPBOARD_SYLK
CLIPBOARD_TEXT
CLIPBOARD_TIFF

Description

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

Discussion

The .VALUE_PUT() method sets the Field_Value of a field referenced by the object pointer. The data type of information supplied through the Field Value parameter must match the field's type. To determine the field type, use the <FIELD>.TYPE_GET() method. You can assign field values when changing or entering records. The .VALUE_PUT() method must be preceded by a <TBL>.CHANGE_BEGIN() or <TBL>.ENTER_BEGIN(), and followed by a corresponding <TBL>.CHANGE_END() or <TBL>.ENTER_END(). If you are not in Change or Enter mode, Alpha Anywhere will generate an error. Alpha Anywhere provides other, more direct, ways of setting 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 = value, e.g. customer->lastname = "Smith"

If you have an object pointer reference to the table:

.fieldname = value , e.g., tbl_1.lastname = "Smith"

Clipboard Format is an optional parameter that specifies the format of the data that is being written. For example, if you wanted to write a bitmap into a field, you would specify CLIPBOARD_DIB as the Clipboard Format. See the "Constants" section in the Xbasic Explorer for a list of Clipboard Formats.

 Example

Change the last name of the current record from the current table.

dim tbl as P
dim fld as P
tbl = table.current()
tbl.change_begin()
    fld = tbl.field_get("last_name")
    fld.value_put("Smith")
tbl.change_end(.T.)

This does the same thing more directly:

dim tbl as P
tbl = table.current()
tbl.change_begin()
tbl.last_name = "Smith"
tbl.change_end(.T.)

This example shows how to put text into an RTF memo field.

dim tbl as P
dim fld as P
dim rtf as P
tbl = table.current()
text = "Send a follow up letter on 1/6/03"
tbl.change_begin()
    fld = tbl.field_get("Memo")
    'create a new RTF object with the text in it
    rtf = :rtf.create(text)
    'Insert the binary_text property of the RTF object into the field
    fld.value_put(rtf.binary_text)
tbl.change_end(.T.)

See Also