Command REPLACE Foundation
Assigns values to field variables.
REPLACE <cFieldname> WITH <Expression> ;
[, <cFieldname> WITH <Expression>... ] ;
[FOR <lForCondition>] ;
[WHILE <lWhileCondition>] ;
[NEXT <nCount>] ;
[RECORD <xRecordID>] ;
[REST] ;
[ALL] ;
The file command REPLACE assigns values to specific field variables. After the key word REPLACE, a list of assignments can be specified (separated by commas) conforming to <Field1> WITH <Expr1>, <FieldN> WITH <ExprN> . The command has the same functionality as the assignment operator (:=). Of course, the variable referenced is always a field variable, even when no alias name is indicated with REPLACE. Values can also be assigned to field variables using the assignment operator when the alias name and alias operator are placed in front of the field name, or when the variable is explicitly declared as a field variable by the declaration FIELD.
When neither a condition nor the number of records are specified, REPLACE works with only the current record by default. Otherwise, the specified number of records or the records matching the condition are used.
In a multi-user application in a network operation, a record must be locked before the command REPLACE is executed or before an assignment occurs.
// In the example, the data for a record is
// read into memory variables which are edited.
// After editing is complete, the variables are
// assigned to the field variables using REPLACE
PROCEDURE Main
LOCAL cPartNo , cPart
USE Part INDEX PartA, PartB ALIAS Part NEW
cPartNo := Part->PartNo
cPart := Part->Part
CLS
@ 10,5 SAY "Part number :" GET cPartNo
@ 11,5 SAY "Part designation:" GET cPart
READ
IF .NOT. Empty( cPartNo + cPart )
REPLACE PartNo WITH cPartNo , ;
Part WITH cPart
ENDIF
CLOSE Part
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.