Clear - BaseData_Set

Clears all tables owned by this object

Type: Procedure

Parameters: None

Syntax
Procedure Clear 

Call: Send Clear


Description

Clear clears all tables owned by this object, including the Main_File, sends Refresh to the data entry objects (DEOs) attached to this object, sets the Changed_State of this object to False and notifies connected DataDictionary objects (DDOs) of the change. This may cause the connected DDOs to clear and/or find, etc. This is sent by DEOs attached to this object.


As of DataFlex 17.0, you can use the DD_Remember field option via Field_RememberedValue to default parent records.

You can use Procedure Clear to default parent table values and find related parent tables when a new record is created.

Sample

For example, if the user is entering sales data and most sales are in Florida, you could default this state in the main (child) Data Dictionary Object (DDO) or class:

Procedure Clear
    forward send Clear
    Send DoDefaultParent
End_Procedure

Procedure DoDefaultparent
     Clear State
     Move "FL" to State.Key
     Find eq State.Key
     if (found) Begin
          Send Request_Assign State.File_Number
          Set Changed_State to False  // see below
     End
End_Procedure

Changed_State is set to false so the user will not get an 'abandon changes' message. When finding a parent DDO, the child's Should_Save gets set to true because there are changed parents. If this is to be a default, that Changed_State should be cleared.

You could also use that to maintain a "retain" parent. Something like this:

Procedure Clear
    Integer ParentRec
    Move MyParent.Recnum to ParentRec
    Forward Send Clear
    Send DoDefaultParent Parentrec
End_Procedure

Procedure DoDefaultparent integer ParentRec
     Clear MyParent
     Move ParentRec to MyParent.recnum
     Find eq MyParent.recnum
     If (Found) Begin
          Send Request_Assign MyParent.File_Number
          Set Changed_State to False
     End
End_Procedure

If you want a Clear_All to do the same thing, you would also need to augment the Clear_All message - same idea.

I would expect that this would normally be done in DD Objects because these type of defaults tend to be a function of the view you are creating.

ReEntrancy

Clear is not re-entrant. Once a major Data-Dictionary operation (save, find, delete, clear) has begun you cannot start another major operation. The reentrancy restriction applies within DDO structures and across DDO structures.

See Also

Clearing - Clear and Clear All