Use Windows.pkg Use DFClient.pkg Deferred_View Activate_oMoveFileList for ; Object oMoveFileList is a dbView Set Border_Style to Border_Normal Set Size to 71 163 Set Location to 2 2 Set Label to "Moving FileList Entries" Set Icon to "Default.Ico" Object oFromNumber is a SpinForm // Object to enter the filelist number you want to move from Set Location to 5 40 Set Size to 14 41 Set Maximum_Position to 4096 Set Minimum_Position to 1 Set Label_Justification_Mode to JMode_Right Set Label_Col_Offset to 2 Set Label to "From:" End_Object Object oToNumber is a SpinForm // Object to enter the filelist number you want to move to Set Location to 5 111 Set Size to 14 41 Set Maximum_Position to 4096 Set Minimum_Position to 1 Set Label_Justification_Mode to JMode_Right Set Label_Col_Offset to 2 Set Label to "To:" End_Object Object oUpdateRelationshipsCheckBox is a CheckBox // Object to specify whether you want the relationship check and modify // to happen Set Size to 14 50 Set Location to 21 40 Set Label to "Update relationships" Set Checked_State To True End_Object Object oMoveFilesButton is a Button Set Location to 33 102 Set Label to "Move files" Procedure OnClick Integer iFrom iTo Boolean bChange String sRootName // Get the user choices Get Checked_State Of oUpdateRelationshipsCheckBox To bChange Get Value Of oFromNumber To iFrom Get Value Of oToNumber To iTo // Validate that the values for FROM and TO are in range If (iFrom = iTo) Begin Send Stop_Box "Numbers need to be different" Procedure_Return End If (iFrom <= 0 Or iFrom > 4096) Begin Send Stop_Box "The range for the from number must be between 1 and 4096" Procedure_Return End If (iTo <= 0 Or iTo > 4096) Begin Send Stop_Box "The range for the to number must be between 1 and 4096" Procedure_Return End // Verify if the TO slot is empty or not Get_Attribute DF_FILE_ROOT_NAME Of iTo To sRootName If (sRootName <> "") Begin Send Stop_Box "Destination filelist slot is in use!" Procedure_Return End // Finally start the move operation Send MoveFileListEntry iFrom iTo bChange End_Procedure End_Object Object oNoErrors Is A cObject // Object to block any error to popup. You can choose to log errors instead // of just ignoring them. Procedure Error_Report Integer iErrNumber Integer iErrLine String sErrMsg End_Procedure End_Object // Function to find out if the passed table number relates to the file you wanted // to move (the move in the original code already happened). Function DoesTableRelatesTo Integer iTable Integer iFrom Returns Boolean Boolean bOpened bRelates Integer iFields iField iRelatedFile // Find out if the table was opened before. If not we want to close // the table prior to leave the function Get_Attribute DF_FILE_OPENED Of iTable To bOpened If (Not (bOpened)) Begin Open iTable End // Enumerate all the columns of the table and if any relates to the // FROM filelist slot return TRUE to the caller Get_Attribute DF_FILE_NUMBER_FIELDS Of iTable To iFields For iField From 1 To iFields Get_Attribute DF_FIELD_RELATED_FILE Of iTable iField To iRelatedFile If (iRelatedFile = iFrom) Begin Move True To bRelates End Loop // If this function opened the table we will close it before leaving If (Not (bOpened)) Begin Close iTable End Function_Return bRelates End_Function // Function to change the relationship of all the columns that relate to // the FROM table. Procedure ChangeRelation Integer iTable Integer iFrom Integer iTo Integer iFields iField iRelatedFile Structure_Start iTable Get_Attribute DF_FILE_NUMBER_FIELDS Of iTable To iFields For iField From 1 To iFields Get_Attribute DF_FIELD_RELATED_FILE Of iTable iField To iRelatedFile If (iRelatedFile = iFrom) Begin Set_Attribute DF_FIELD_RELATED_FILE Of iTable iField To iTo End Loop Structure_End iTable End_Procedure // Move the filelist entry and check/update relationship information Procedure MoveFileListEntry Integer iFrom Integer iTo Boolean bChange String sRootName sDisplayName sLogicalName Integer iFile Handle hoErrors Boolean bRelatesTo bOpened bOpenedBefore // Store the current values Get_Attribute DF_FILE_ROOT_NAME Of iFrom To sRootName Get_Attribute DF_FILE_LOGICAL_NAME Of iFrom To sLogicalName Get_Attribute DF_FILE_DISPLAY_NAME Of iFrom To sDisplayName // Erase the current filelist entries Set_Attribute DF_FILE_ROOT_NAME Of iFrom To "" Set_Attribute DF_FILE_LOGICAL_NAME Of iFrom To "" Set_Attribute DF_FILE_DISPLAY_NAME Of iFrom To "" // Set the filelist entries of thje TO table to the copied information Set_Attribute DF_FILE_ROOT_NAME Of iTo To sRootName Set_Attribute DF_FILE_LOGICAL_NAME Of iTo To sLogicalName Set_Attribute DF_FILE_DISPLAY_NAME Of iTo To sDisplayName // If no relationship test needs to be done, skip that code by // terminating this procedure If (Not (bChange)) Begin Procedure_Return End // Store the error object id and make an object inside this view // responsible for handling the errors. Move Error_Object_Id To hoErrors Move oNoErrors To Error_Object_Id // Enumerate all the filelist entries Move 0 To iFile Repeat Get_Attribute DF_FILE_NEXT_USED Of iFile To iFile If (iFile > 0 And iFile <> iTo) Begin // If an entry was found call a function to find out if // the table relates to the FROM table Get DoesTableRelatesTo iFile iFrom To bRelatesTo If (bRelatesTo) Begin // If it relates find out if the table was opened before // if so we want to restore that state at the end of our // operations Get_Attribute DF_FILE_OPENED Of iFile To bOpenedBefore If (bOpenedBefore) Begin Close iFile End // Try to open the table in exclusive mode Open iFile Mode DF_EXCLUSIVE // Find out if the open was succesfull or not Get_Attribute DF_FILE_OPENED Of iFile To bOpened If (bOpened) Begin // If we have the table open we can change the // relationship information Send ChangeRelation iFile iFrom iTo End // If the table was opened before open it again // the structure change closes the table If (bOpenedBefore) Begin Open iFile End End End Until (iFile = 0) // Restore the error object handle Move hoErrors To Error_Object_Id End_Procedure CD_End_Object