Use Dfclient.pkg Object Kopier_fra_database is a dbModalPanel Set Label to "Copy from database" Set Location to 6 17 // Visual DataFlex 14.0 Client Size Adjuster, modified May 7, 2008: 13:11:32 // Set Size to 326 328 Set Size to 311 325 Set Border_Style to Border_Dialog Object filTil is a Form Set Label to "Filename To:" Set Size to 13 252 Set Location to 5 65 Set peAnchors to anTopLeftRight Set enabled_state To False End_Object // filTil Object filFra is a Form Set Label to "Filename From:" Set Size to 13 252 Set Location to 20 65 Set peAnchors to anTopLeftRight Set Prompt_Button_Mode to pb_PromptOn Procedure Prompt String sInitDir sValgtFil sTilFil Move (vSelect_File("Datafiles (*.dat;*.int)|*.dat;*.int|Dataflex file (*.dat)|*.dat|Driverbased files (*.int)|*.int", "Choose file", "")) To sValgtFil If (Trim(sValgtFil) <> "") Begin Get value Of filTil To sTilFil If (Trim(Uppercase(sTilFil)) = Trim(Uppercase(sValgtFil))) Begin Send info_box "The file has already been selected as Filename To!" Set value To "" End Else Begin Set value To sValgtFil Send DoFillList Of oFelterTil Send DoFillList Of oFelterFra End End End_Procedure End_Object // filFra Object oBox is a Container3d Set Size to 234 319 Set Location to 37 2 Object oFlettede is a Grid Set Size to 111 247 Set Location to 16 34 Set Resize_Column_state to FALSE Set Highlight_Row_state to TRUE Set peDisabledTextColor to clWindowText Set pbUseDisabledColor to TRUE Set Line_Width to 2 0 Set Form_Width item 0 to 120 Set Header_Label item 0 to "To" Set Form_Width item 1 to 120 Set Header_Label item 1 to "From" On_Key Key_Shift+Key_F2 Send SletRaekke //Set Read_only_state to true // example method of how to fill a grid //Procedure DoFillGrid // Integer i iMaxRows // move 20 to iMaxRows // for i from 1 to iMaxRows // send Add_Item msg_None ("Col 1, row "+(string(i)) ) // send Add_Item msg_None ("Col 2, row "+(string(i)) ) // send Add_Item msg_None ("Col 3, row "+(string(i)) ) // loop //End_Procedure // DoFillGrid //Procedure OnChange integer iNewItem // string sValue // get Value iNewItem to sValue // value of changed cell // //End_Procedure // OnChange Procedure Add_Item Integer iMsg String sTekst Integer iItem Get item_count To iItem Forward Send Add_item iMsg sTekst Set shadow_state Item iItem To True End_Procedure Procedure SletRaekke Integer iItem Integer iRow String sTil sFra Get item_count To iItem If (iItem = 0) Procedure_Return Get current_item To iItem Move (iItem/2) To iRow Move (iRow*2) To iItem Get value Item iItem To sTil Send Delete_Item iItem Get value Item iItem To sFra Send Delete_Item iItem Send Add_Item Of oFelterTil msg_None sTil Send Add_Item Of oFelterFra msg_None sFra End_Procedure End_Object // oFlettede Object oTextBox1 is a Textbox Set Label to "Joined fields" Set Auto_Size_State to FALSE Set Location to 4 34 Set Size to 10 247 Set Justification_Mode to jMode_Center End_Object // oTextBox1 Object oFelterTil is a List Set Label to "TO:" Set Size to 62 120 Set Location to 143 6 Set Label_Col_Offset to 0 Set Label_Justification_Mode to jMode_Top Procedure DoFillList String sFil // Fill the list by sending Add_item Get value Of filTil To sFil Send Delete_Data Send HentFeltNavne sFil Self End_Procedure // DoFillList //Send DoFillList // message must be sent to fill the list //Procedure OnChange // Integer iCurrent // Get Current_item to iCurrent // item number of current item // //End_Procedure // OnChange End_Object // oFelterTil Object oFlet is a Button Set Label to "Join selected fields" Set Size to 38 50 Set Location to 143 133 Set MultiLineState to TRUE Procedure OnClick Integer iItem iItem2 Boolean bValgt String sFeltFra sFeltTil Get item_count Of oFelterTil To iItem If (iItem = 0) Procedure_Return Get item_count Of oFelterFra To iItem If (iItem = 0) Procedure_Return Get Current_item Of oFelterTil To iItem Get Select_state Of oFelterTil Item iItem To bValgt If (bValgt = False) Procedure_Return Get value Of oFelterTil Item iItem To sFeltTil If (sFeltTil = "") Procedure_Return Get Current_item Of oFelterFra To iItem2 Get Select_state Of oFelterFra Item iItem2 To bValgt If (bValgt = False) Procedure_Return Get value Of oFelterFra Item iItem2 To sFeltFra If (sFeltFra = "") Procedure_Return Send Add_Item Of oFlettede msg_None sFeltTil Send Add_Item Of oFlettede msg_None sFeltFra Send Delete_Item Of oFelterTil iItem Send Delete_Item Of oFelterFra iItem2 End_Procedure // OnClick End_Object // oFlet Object oFletAlle is a Button Set Label to "Join all fields with the same name" Set Size to 38 50 Set Location to 187 133 Set MultiLineState to TRUE Procedure OnClick Integer iFra iTil iMaxFra iMaxTil String sTil sFra Get item_count Of oFelterTil To iMaxTil If (iMaxTil = 0) Procedure_Return Get item_count Of oFelterFra To iMaxFra If (iMaxFra = 0) Procedure_Return Move 0 To iTil While (iTil < iMaxTil) Get value Of oFelterTil Item iTil To sTil Move 0 To iFra While (iFra < iMaxFra) Get value Of oFelterFra Item iFra To sFra If (sTil = sFra) Begin Set current_item Of oFelterTil To iTil Set current_item Of oFelterFra To iFra Set select_state Of oFelterTil Item iTil To True Set select_state Of oFelterFra Item iFra To True Send KeyAction Of oFlet Get item_count Of oFelterTil To iMaxTil If (iMaxTil = 0) Procedure_Return Get item_count Of oFelterFra To iMaxFra If (iMaxFra = 0) Procedure_Return Move -1 To iTil Move 999 To iFra End Else Increment iFra Loop Increment iTil Loop End_Procedure // OnClick End_Object // oFletAlle Object oFelterFra is a List Set Label to "FROM:" Set Size to 62 120 Set Location to 143 188 Set Label_Col_Offset to 0 Set Label_Justification_Mode to jMode_Top Procedure DoFillList String sFil // Fill the list by sending Add_item Get value Of filFra To sFil Send Delete_Data Of oFlettede Send Delete_Data Send HentFeltNavne sFil Self End_Procedure // DoFillList //Send DoFillList // message must be sent to fill the list //Procedure OnChange // Integer iCurrent // Get Current_item to iCurrent // item number of current item // //End_Procedure // OnChange End_Object // oFelterFra End_Object // oBox Object cmbIndex is a ComboForm Set Label to "Update by Index:" Set Size to 14 259 Set Location to 274 62 Set peAnchors to anTopLeftRight Set Form_Border to 0 Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right Set Entry_State Item 0 to FALSE Procedure Combo_Fill_List Integer AntalIndex aktIndex antalSegmenter aktSegment Feltnr iVal String sBesked strTemp Integer iFile Get piFileNumber To iFile Send Combo_delete_data Send Combo_Add_Item "00: (Add records only)" // ingen index - brug recnum Get_Attribute DF_FILE_LAST_INDEX_NUMBER Of iFile To AntalIndex For aktIndex From 1 To antalIndex Get_Attribute DF_INDEX_NUMBER_SEGMENTS Of iFile (String(aktIndex)) To antalSegmenter If antalSegmenter Begin Move "" To sBesked If (aktIndex < 10) Append sBesked "0" Append sBesked aktIndex Append sBesked ": " For aktSegment From 1 To antalSegmenter Get_Attribute DF_INDEX_SEGMENT_FIELD Of iFile (String(aktIndex)) (String(aktSegment)) To feltnr Get string_value Of (aFildef(Self)) Item (feltnr * 4) To strTemp Append sBesked strTemp //Get_attribute DF_INDEX_SEGMENT_CASE of cFilnr (string(aktIndex)) (string(aktSegment)) to iVal //If (iVal = DF_CASE_USED) append sBesked "(UPP)" Get_Attribute DF_INDEX_SEGMENT_DIRECTION Of iFile (String(aktIndex)) (String(aktSegment)) To iVal If (iVal = DF_DESCENDING) Append sBesked "(DEC)" Append sBesked ", " Loop Trim sBesked To sBesked If (Right(sBesked, 1) = ",") Move (Left(sBesked, (Length(sBesked) - 1))) To sBesked Send Combo_Add_Item sBesked End Loop Set value Item 0 To "00: (Add records only)" End_Procedure End_Object // cmbIndex Object oOK_bn is a Button Set Label to "&Start" Set Location to 293 217 Procedure OnClick Integer iAntalNyePoster iMax iNumFields iAktField iAkt Integer FilenumFra FilenumTil iRecordsBefore iRecordsAfter Integer iMaxFraRec iAktFraRec iOldPct iAktPct iIndex iUpdated Integer iFile Handle hoFeltFra hoFeltTil String sFilTil sFilFra sFeltnavn sChkFelt sData sVal Boolean bFound bSave Get value Of cmbIndex Item 0 To sVal Left sVal To iIndex 2 Get item_count Of oFlettede To iMax If (iMax = 0) Procedure_Return Get NextFreeFilenumber To FilenumFra If (FilenumFra = 0) Procedure_Return Get NextFreeFilenumber FilenumFra To FilenumTil If (FilenumTil = 0) Procedure_Return Send DoShowWorking "Copying records." Get value Of filTil To sFilTil Get value Of filFra To sFilFra Get create U_array To hoFeltFra If (hoFeltFra = 0) Procedure_Return Get Create U_Array To hoFeltTil If (hoFeltTil = 0) Procedure_Return Get piFileNumber To iFile Close iFile // Prevent lock problems Get DriverForOpenAs sFilTil To sFilTil Get DriverForOpenAs sFilFra To sFilFra Open sFilTil as FilenumTil Mode DF_SHARE Open sFilFra as FilenumFra Mode DF_SHARE Get_Attribute DF_FILE_RECORDS_USED Of FilenumTil To iRecordsBefore Move 0 To iAkt While (iAkt < iMax) Get value Of oFlettede Item iAkt To sChkFelt Get_Attribute DF_FILE_NUMBER_FIELDS Of FilenumTil To iNumFields For iAktField From 1 To iNumFields Get_Attribute DF_FIELD_NAME Of FilenumTil iAktField To sFeltnavn If (sFeltNavn = sChkFelt) Begin Set value Of hoFeltTil Item (item_count(hoFeltTil)) To iAktField Move iNumFields To iAktField End Loop Move (iAkt + 2) To iAkt Loop Move 1 To iAkt While (iAkt < iMax) Get value Of oFlettede Item iAkt To sChkFelt Get_Attribute DF_FILE_NUMBER_FIELDS Of FilenumFra To iNumFields For iAktField From 1 To iNumFields Get_Attribute DF_FIELD_NAME Of FilenumFra iAktField To sFeltnavn If (sFeltNavn = sChkFelt) Begin Set value Of hoFeltFra Item (item_count(hoFeltFra)) To iAktField Move iNumFields To iAktField End Loop Move (iAkt + 2) To iAkt Loop Get item_count Of hoFeltFra To iMax Decrement iMax Send ignore_all Of error_info_object Move 0 To iAktFraRec Move 0 To iUpdated Move False To bFound Move -1 To iOldPct Get_Attribute DF_FILE_RECORDS_USED Of FilenumFra To iMaxFraRec Clear FilenumFra Vfind FilenumFra 0 Gt Increment iAktFraRec While (iAktFraRec <= iMaxFraRec) Move ((iAktFraRec * 1000.0) / iMaxFraRec) To iAktPct If (iAktPct <> iOldPct) Begin Move iAktPct To iOldPct Set label Of (tekst2(info_panel)) To (String(iAktPct / 10.0)) End Lock Clear FilenumTil For iAkt From 0 To iMax Get integer_value Of hoFeltFra Item iAkt To iAktField Get_Field_Value FilenumFra iAktField To sData Get integer_value Of hoFeltTil Item iAkt To iAktField Set_Field_Value FilenumTil iAktField To sData Loop If (iIndex > 0) Begin // Try updating an existing record, else save new Move False To bSave Vfind FilenumTil iIndex Eq Move (Found) To bFound If (Not(bFound)) Clear FilenumTil For iAkt From 0 To iMax Get integer_value Of hoFeltFra Item iAkt To iAktField Get_Field_Value FilenumFra iAktField To sData Get integer_value Of hoFeltTil Item iAkt To iAktField Get_Field_Value FilenumTil iAktField To sVal If (sVal <> sData) Begin Set_Field_Value FilenumTil iAktField To sData Move True To bSave End Loop End Else Move True To bSave If (bSave) Begin Indicate Err False Saverecord FilenumTil If ((bFound) And (Not(err))) Increment iUpdated End Unlock Vfind FilenumFra 0 Gt Increment iAktFraRec Loop Send trap_all Of error_info_object Send Destroy Of hoFeltFra Send Destroy Of hoFeltTil Get_Attribute DF_FILE_RECORDS_USED Of FilenumTil To iRecordsAfter Close FilenumFra Close FilenumTil Set pbUndersoegFil of oEditorView to True Send DoLukInfopanel Move ("Number of new records:"*String(iRecordsAfter-iRecordsBefore)) To sVal Append sVal "\nNumber of updated records: " (String(iUpdated)) Send info_box sVal End_Procedure End_Object // oOK_bn Object oAnnuller_bn is a Button Set Label to "&Cancel" Set Location to 293 271 Procedure OnClick Send Request_cancel End_Procedure End_Object // oAnnuller_bn On_Key Key_Alt+Key_S Send KeyAction To oOk_bn On_Key Key_Alt+Key_C Send KeyAction To oAnnuller_bn On_Key kCancel Send close_panel Procedure Popup String sValgtFil Get psFilename To sValgtFil If (sValgtFil = "") Procedure_Return Set value Of filTil To sValgtFil Set value Of filFra To "" Send delete_Data Of oFlettede Send delete_Data Of oFelterTil Send Delete_Data Of oFelterFra Send DoFillList Of oFelterTil Send Combo_Fill_List Of cmbIndex Forward Send Popup End_Procedure Procedure HentFeltNavne String sFil Integer oID Integer iNumFields iAktField Filenum iFile String sFeltnavn If (oID = 0) Procedure_Return Get piFilenumber To iFile Get NextFreeFilenumber iFile To Filenum If (Filenum = 0) Procedure_Return Get DriverForOpenAs sFil To sFil Open sFil as Filenum Mode DF_SHARE If (Found) Begin Get_Attribute DF_FILE_NUMBER_FIELDS Of Filenum To iNumFields For iAktField From 1 To iNumFields Get_Attribute DF_FIELD_NAME Of Filenum iAktField To sFeltnavn Send Add_Item Of oID msg_None sFeltnavn Loop End Close Filenum End_Procedure End_Object // Kopier_fra_database