Replaces fields in the current table that have corresponding automem variables.

Syntax

REPLACE AUTOMEM

Description

Automem variables are private or public memory variables that have the same name as the corresponding fields of the current table. Automem variables are used to hold data that will be stored in the fields of records. You can manipulate data stored in automem variables as memory variables rather than as field values, and you can validate the data before storing the data to a table.

Create a set of automem variables for the fields in a table with USE...AUTOMEM, CLEAR AUTOMEM, or STORE AUTOMEM (or create the variable manually). To add new records to a table and fill the fields with values from corresponding automem variables, use APPEND AUTOMEM. To update the fields of existing records with values from corresponding automem variables, use REPLACE AUTOMEM.

Use REPLACE AUTOMEM to update all the fields of a record without having to name the fields. By contrast, with the REPLACE command, you need to name every field you want updated.

Remember that an automem variable and its corresponding field have the same name. When a command allows an argument that could be either a field or a private or public memory variable, dBASE Plus assumes the argument refers to a field. To distinguish the memory variable from the field, prefix the names of automem variables with M->.

REPLACE AUTOMEM updates the current record. It can't update all records within a specified scope or all records matching a condition, as the REPLACE command can with the options <scope>, FOR <condition>, and WHILE <condition>.

REPLACE AUTOMEM doesn't replace field data with data from a memory variable with the same name but of a different data type. Those variables are ignored. If a field does not have a corresponding private or public variable with the same name, that field is left unchanged.

Note: Read-only field type - Autoincrement

Because APPEND AUTOMEM and REPLACE AUTOMEM write values to your table, the contents of the read-only field type, Autoincrement, must be released before using either of these commands. In the following example, the autoincrement field is represented by "myAutoInc":

use table1 in 1

use table2 in 2

select 1      // navigate to record

store automem

release m->myAutoInc 

select 2       // navigate to record

replace automem

OODML

The Rowset object contains an array of Field objects, accessed through its fields property. These Field objects have value properties that may be programmed like variables.