Skip to content

Inactivate Command

Obsolete

This command is obsolete. It is valid only in character-mode DataFlex. There is no Windows equivalent for this option.

Purpose

To render the record in the buffer inactive.

Syntax

inactivate
fileName
[keep]

What It Does

The inactivate command makes an active record inactive by moving a 0 to the record's recnum. Unlike the clear command, it retains all current field values. Once a record is inactivated, data may be moved into the record's fields without the dreaded "Edited Record Not Saved" error occurring. Inactivate is often used when you need to change a field's value before performing a find (allowing you to jump around in an index, for example).

If the keep parameter is passed, the recnum value is maintained in the record. When keep is used, a 0 is moved to the recnum (inactivating the record), and then the original record number is moved back into recnum. The result is an inactive record that still contains the original record number.

Be careful about saving a record that has been inactivated. Once a record is inactivated, it will be saved as a new record with a new record number (even if you use the keep parameter). This can actually be used as a feature if you need to duplicate a record (assuming that the duplication will not result in a duplicate index error).

You could also inactivate a record by entering the statement move 0 to file.field. The advantage of the inactivate command is that it makes the programmer's intent clearer.

Example

Assume that you are performing an update where you are changing all Vendors' status from A to I. The field vendor.status is an indexed field. The quickest way to make this update is to find all vendor statuses with an A by the vendor.status index. The problem that arises is that each save changes the status index value, which we must then reset so that our finds continue in order. If you reset vendor.status by placing an A back into vendor.status without first inactivating the record, you're going to get an error message!

Clear Vendor                             // start of file
Move 'A' to Vendor.Status                // seed the index
Repeat
    Find Gt Vendor.Status                // get record
    [Found] Ind Found as Vendor.Status eq 'A' // is it A?
    [Not Found] Break                    // If not 'A' or no rec.. exit.
    Move 'I' to Vendor.Status            // change status
    SaveRecord Vendor                    // save it
    Inactivate Vendor KEEP               // now..restore index for
    Move 'A' to Vendor.Status            // the next find
Loop