//AB/ Project Import textfile //AB/ Object prj is a Dialog_Project //AB/ Set Size to 362 558 //AB/ Set ProjectName to "Import textfile" //AB/ Set ProjectFileName to "Import_textfile.dg" //AB/ Set GenerateFileName to "NONAME" // Project Object Structure // Import_textfile is a ModalPanel // oOK_btn is a Button // oCancel_btn is a Button // oCntHeader is a Container3d // oTextFormat is a RadioGroup // oFixed is a Radio // oSeperator is a Radio // oFieldSeperator is a ComboForm // oText is a ComboForm // oCodepage is a RadioGroup // oANSI is a Radio // oOEM is a Radio // oFirstRow is a CheckBox // oDateFormat is a ComboForm // oDateSeperator is a ComboForm // oFourDigitYear is a CheckBox // oDecimalsign is a ComboForm // oCntData is a Container3d // oData is a Grid // oTextBox1 is a Textbox // oCntFields is a Container3d // oFields is a Grid // oTextBox2 is a Textbox // oFldAdd_bn is a Button // oFldInsert_bn is a Button // oFldDelete is a Button // oRefresh_bn is a Button // oSave is a Button // oLoad is a Button // oSaveAsDialog is a SaveAsDialog // Register all objects Register_Object Import_textfile Register_Object oANSI Register_Object oCancel_btn Register_Object oCntData Register_Object oCntFields Register_Object oCntHeader Register_Object oCodepage Register_Object oData Register_Object oDateFormat Register_Object oDateSeperator Register_Object oDecimalsign Register_Object oFieldSeperator Register_Object oFields Register_Object oFirstRow Register_Object oFixed Register_Object oFldAdd_bn Register_Object oFldDelete Register_Object oFldInsert_bn Register_Object oFourDigitYear Register_Object oLoad Register_Object oOEM Register_Object oOK_btn Register_Object oRefresh_bn Register_Object oSave Register_Object oSaveAsDialog Register_Object oSeperator Register_Object oText Register_Object oTextBox1 Register_Object oTextBox2 Register_Object oTextFormat //AB-StoreTopStart //AB-StoreTopEnd //AB-IgnoreStart Use Windows.pkg Use dfRadio.pkg Use dfCmbFrm.pkg Use File_dlg.Pkg //AB-IgnoreEnd Object Import_textfile is a ModalPanel Set Border_Style to Border_Thick Set Label to "Import textfile" Set Location to 4 7 Set Size to 310 521 Set piMinSize to 104 217 //AB-DDOStart //AB-DDOEnd Object oOK_btn is a Button Set Label to "&OK" Set Location to 272 403 Set peAnchors to anBottomRight //AB-StoreStart Procedure OnClick Send Close_Panel End_Procedure // OnClick //AB-StoreEnd End_Object // oOK_btn Object oCancel_btn is a Button Set Label to "&Cancel" Set Location to 272 457 Set peAnchors to anBottomRight //AB-StoreStart Procedure OnClick Send Delete_data of aFields Send Close_Panel End_Procedure // OnClick //AB-StoreEnd End_Object // oCancel_btn Object oCntHeader is a Container3d Set Size to 111 233 Set Location to 2 2 Object oTextFormat is a RadioGroup Set Size to 39 77 Set Location to 4 12 Set Label to "Textformat" Object oFixed is a Radio Set Label to "Fixed length." Set Size to 10 57 Set Location to 10 5 End_Object // oFixed Object oSeperator is a Radio Set Label to "Seperator." Set Size to 10 49 Set Location to 25 5 End_Object // oSeperator //AB-StoreStart Procedure Notify_Select_State Integer iToItem Integer iFromItem Forward Send Notify_Select_State iToItem iFromItem //for augmentation If (iToItem = 0) Begin Set pbTextFormatIsFixedLength to True Send Delete_data of oFields Set Line_Width of oFields to 5 0 Set Form_Width of oFields Item 0 to 100 Set Header_Label of oFields Item 0 to "Name" Set Form_Width of oFields Item 1 to 50 Set Header_Label of oFields Item 1 to "Type" Set Form_Width of oFields Item 2 to 40 Set Header_Label of oFields Item 2 to "Start" Set Form_Width of oFields Item 3 to 40 Set Header_Label of oFields Item 3 to "Length" Set Form_Width of oFields Item 4 to 30 Set Header_Label of oFields Item 4 to "Skip" Set enabled_state of oFieldSeperator to False Set enabled_state of oText to False Set Enabled_state of oFldAdd_bn to True Set Enabled_state of oFldInsert_bn to True Set Enabled_state of oFldDelete to True End Else Begin Set pbTextFormatIsFixedLength to False Send Delete_data of oFields Set Line_Width of oFields to 4 0 Set Form_Width of oFields Item 0 to 135 Set Header_Label of oFields Item 0 to "Name" Set Form_Width of oFields Item 1 to 50 Set Header_Label of oFields Item 1 to "Type" Set Form_Width of oFields Item 2 to 30 Set Header_Label of oFields Item 2 to "Skip" Set Form_Width of oFields Item 3 to 40 Set Header_Label of oFields Item 3 to "Max. length" Set enabled_state of oFieldSeperator to True Set enabled_state of oText to True Set Enabled_state of oFldAdd_bn to False Set Enabled_state of oFldInsert_bn to False Set Enabled_state of oFldDelete to False End Send Preload_file End_Procedure // Notify_Select_State // If you set Current_radio you must set this after the // radio objects have been created AND after Notify_select_State has been // created. i.e. Set in bottom-code at end!! //Set Current_Radio To 1 //AB-StoreEnd End_Object // oTextFormat Object oFieldSeperator is a ComboForm Set Label to "Field seperator:" Set Size to 13 67 Set Location to 5 157 Set Form_Border to 0 Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right Set Combo_Sort_State to FALSE //AB-StoreStart // Combo_Fill_List is called when the list needs filling Procedure Combo_Fill_List // Fill the combo list with Send Combo_Add_Item Send Combo_Add_Item "," Send Combo_Add_Item ";" Send Combo_Add_Item "{Tabulator}" Send Combo_Add_Item "{Space}" End_Procedure // Combo_Fill_List // notification of a selection change or edit change Procedure OnChange String sValue Get Value to sValue // the current selected item If (sValue = "{Tabulator}") Move (Character(9)) to sValue If (sValue = "{Space}") Move " " to sValue Set psFieldSeperator to (Left(sValue, 1)) End_Procedure // OnChange // notification that the list has dropped down //Procedure OnDropDown //End_Procedure // OnDropDown // notification that the list was closed //Procedure OnCloseUp //End_Procedure // OnCloseUp //AB-StoreEnd End_Object // oFieldSeperator Object oText is a ComboForm Set Label to "Text qualification:" Set Size to 13 67 Set Location to 20 157 Set Form_Border to 0 Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right Set Combo_Sort_State to FALSE //AB-StoreStart // Combo_Fill_List is called when the list needs filling Procedure Combo_Fill_List // Fill the combo list with Send Combo_Add_Item Send Combo_Add_Item '"' Send Combo_Add_Item "'" End_Procedure // Combo_Fill_List // notification of a selection change or edit change Procedure OnChange String sValue Get Value to sValue // the current selected item Set psTextQualification to (Left(sValue, 1)) End_Procedure // OnChange // notification that the list has dropped down //Procedure OnDropDown //End_Procedure // OnDropDown // notification that the list was closed //Procedure OnCloseUp //End_Procedure // OnCloseUp //AB-StoreEnd End_Object // oText Object oCodepage is a RadioGroup Set Size to 39 77 Set Location to 46 12 Set Label to "Codepage" Object oANSI is a Radio Set Label to "ANSI." Set Size to 10 35 Set Location to 10 5 End_Object // oANSI Object oOEM is a Radio Set Label to "OEM." Set Size to 10 35 Set Location to 25 5 End_Object // oOEM //AB-StoreStart Procedure Notify_Select_State Integer iToItem Integer iFromItem Forward Send Notify_Select_State iToItem iFromItem //for augmentation If (iToItem = 0) Set pbToOEM to True Else Set pbToOEM to False Send Preload_file End_Procedure // Notify_Select_State // If you set Current_radio you must set this after the // radio objects have been created AND after Notify_select_State has been // created. i.e. Set in bottom-code at end!! // Set Current_Radio To 0 //AB-StoreEnd End_Object // oCodepage Object oFirstRow is a CheckBox Set Label to "First row contains field names." Set Size to 10 111 Set Location to 91 11 //AB-StoreStart Procedure OnChange Boolean bChecked Get Checked_State to bChecked Set pbFirstRowIsFieldNames to bChecked Send Preload_file End_Procedure // OnChange //AB-StoreEnd End_Object // oFirstRow Object oDateFormat is a ComboForm Set Label to "Date format:" Set Size to 13 67 Set Location to 34 157 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 Set Combo_Sort_State to FALSE //AB-StoreStart Set capslock_state to True // Combo_Fill_List is called when the list needs filling Procedure Combo_Fill_List String sValue sYear sDateSep Boolean bFourYear // Fill the combo list with Send Combo_Add_Item Send Combo_delete_data Get psDateSeperator to sDateSep Get pbFourDigitYear to bFourYear Move "YY" to sYear If (bFourYear = True) Move "YYYY" to sYear Move "" to sValue Append sValue "DD" sDateSep "MM" sDateSep sYear // European format Send Combo_Add_Item sValue Move "" to sValue Append sValue "MM" sDateSep "DD" sDateSep sYear // USA format Send Combo_Add_Item sValue Move "" to sValue Append sValue sYear sDateSep "MM" sDateSep "DD" // Military format Send Combo_Add_Item sValue End_Procedure // Combo_Fill_List // notification of a selection change or edit change Procedure OnChange String sValue Get Value to sValue // the current selected item Set psDateFormat to sValue End_Procedure // OnChange // notification that the list has dropped down //Procedure OnDropDown //End_Procedure // OnDropDown // notification that the list was closed //Procedure OnCloseUp //End_Procedure // OnCloseUp //AB-StoreEnd End_Object // oDateFormat Object oDateSeperator is a ComboForm Set Label to "Date seperator:" Set Size to 13 67 Set Location to 50 157 Set Form_Border to 0 Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right Set Combo_Sort_State to FALSE //AB-StoreStart // Combo_Fill_List is called when the list needs filling Procedure Combo_Fill_List // Fill the combo list with Send Combo_Add_Item Send Combo_Add_Item "-" Send Combo_Add_Item "/" End_Procedure // Combo_Fill_List // notification of a selection change or edit change Procedure OnChange String sValue Get Value to sValue // the current selected item Set psDateSeperator to (Left(sValue, 1)) Send Combo_fill_list of oDateFormat End_Procedure // OnChange // notification that the list has dropped down //Procedure OnDropDown //End_Procedure // OnDropDown // notification that the list was closed //Procedure OnCloseUp //End_Procedure // OnCloseUp //AB-StoreEnd End_Object // oDateSeperator Object oFourDigitYear is a CheckBox Set Label to "Four digit year." Set Size to 10 63 Set Location to 65 157 //AB-StoreStart Set checked_state to True Procedure OnChange Boolean bChecked Get checked_state to bChecked Set pbFourDigitYear to bChecked Send Combo_fill_list of oDateFormat End_Procedure // OnChange //AB-StoreEnd End_Object // oFourDigitYear Object oDecimalsign is a ComboForm Set Label to "Decimal sign:" Set Size to 13 67 Set Location to 77 157 Set Form_Border to 0 Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right //AB-StoreStart // Combo_Fill_List is called when the list needs filling Procedure Combo_Fill_List // Fill the combo list with Send Combo_Add_Item Send Combo_Add_Item "," Send Combo_Add_Item "." End_Procedure // Combo_Fill_List // notification of a selection change or edit change Procedure OnChange String sValue Get Value to sValue // the current selected item Set psDecimalSign to (Left(sValue, 1)) End_Procedure // OnChange // notification that the list has dropped down //Procedure OnDropDown //End_Procedure // OnDropDown // notification that the list was closed //Procedure OnCloseUp //End_Procedure // OnCloseUp //AB-StoreEnd End_Object // oDecimalsign End_Object // oCntHeader Object oCntData is a Container3d Set Size to 153 511 Set Location to 114 2 Object oData is a Grid Set Size to 132 501 Set Location to 14 3 Set peResizeColumn to rcNone Set peDisabledTextColor to clBlack Set pbUseDisabledColor to TRUE Set Line_Width to 3 0 Set Form_Width item 0 to 47 Set Header_Label item 0 to "Column 1" Set Form_Width item 1 to 47 Set Header_Label item 1 to "Column 2" Set Form_Width item 2 to 47 Set Header_Label item 2 to "Column 3" //AB-StoreStart //Procedure OnChange Integer iNewItem // String sValue // // Get Value iNewItem To sValue // value of changed cell //End_Procedure // OnChange Procedure DoInitialiseGrid Integer iNoFields iCnt iType iLng iColumns iOldState String sFieldname sMask Boolean bSkip Number nLength nRight Get dynamic_update_state to iOldState Set dynamic_update_state to False Send Delete_data Get NumberOfImportFields of aFields to iColumns Set Line_Width to iColumns 0 Move 0 to iColumns Get NumberOfFields of aFields to iNoFields For iCnt From 1 to iNoFields Get FieldSkip of aFields iCnt to bSkip If (bSkip = False) Begin Get FieldType of aFields iCnt to iType If (iType = C_TEXTFIELDTYPE_ASCII) Begin Move 100 to iLng Set Header_Justification_Mode Item iColumns to jMode_Left Set form_datatype Item iColumns to ascii_window Set Form_Typeface Item iColumns to "COURIER" End If (iType = C_TEXTFIELDTYPE_NUMERIC) Begin Move 60 to iLng Set Header_Justification_Mode Item iColumns to jMode_Right Set form_datatype Item iColumns to mask_numeric_window Get FieldLength of aFields iCnt to nLength Move ((nLength - Integer(nLength)) * 10.0) to nRight Get Maske nLength nRight to sMask Set form_mask Item iColumns to sMask Set Form_Typeface Item iColumns to "COURIER" End If (iType = C_TEXTFIELDTYPE_DATE) Begin Move 45 to iLng Set Header_Justification_Mode Item iColumns to jMode_Left Set form_datatype Item iColumns to ascii_window Set Form_Typeface Item iColumns to "COURIER" End Set Form_Width Item iColumns to iLng Get Fieldname of aFields iCnt to sFieldname Set Header_Label Item iColumns to sFieldname Increment iColumns End Loop Set dynamic_update_state to iOldState End_Procedure Procedure DoShowData Integer iNoFields iCnt iColumns iItem iOldState iType Boolean bSkip String sData Get dynamic_update_state to iOldState Set dynamic_update_state to False Get NumberOfImportFields of aFields to iColumns Get NumberOfFields of aFields to iNoFields Move 0 to iColumns For iCnt From 1 to iNoFields Get FieldSkip of aFields iCnt to bSkip If (bSkip = False) Begin Get DataFromField iCnt to sData Send Add_Item msg_none sData Get item_count to iItem Decrement iItem Set item_shadow_state Item iItem to True End Loop Set dynamic_update_state to iOldState End_Procedure //AB-StoreEnd End_Object // oData Object oTextBox1 is a Textbox Set Label to "Example of data (first 50 rows) as imported:" Set Location to 2 3 Set Size to 10 135 Set TypeFace to "MS Sans Serif" End_Object // oTextBox1 End_Object // oCntData Object oCntFields is a Container3d Set Size to 111 276 Set Location to 2 237 Object oFields is a Grid Set Size to 74 266 Set Location to 12 3 Set Line_Width to 2 0 Set Form_Width item 0 to 142 Set Header_Label item 0 to "Column 1" Set Form_Width item 1 to 112 Set Header_Label item 1 to "Column 2" //AB-StoreStart Set select_mode to multi_select // example method of how to fill a grid Procedure DoFillGrid Integer iRow iMaxRows iVal Integer iItem iOldState String sVal Boolean bFixed bVal Get dynamic_update_state to iOldState Set dynamic_update_state to False Send Delete_data Get NumberOfFields of aFields to iMaxRows Get pbTextFormatIsFixedLength to bFixed For iRow From 1 to iMaxRows Get FieldName of aFields iRow to sVal Send Add_item msg_none sVal Get FieldType of aFields iRow to sVal Get FieldTypeToString of aFields sVal to sVal Send Add_item msg_none sVal Get item_count to iItem Decrement iItem Set Form_button iItem to FORM_BUTTON_SPIN If (bFixed = True) Begin Get FieldStart of aFields iRow to sVal Send Add_item msg_none sVal Get FieldLength of aFields iRow to sVal Send Add_item msg_none sVal Get FieldSkip of aFields iRow to sVal Send Add_item msg_none "" Get item_count to iItem Decrement iItem Set checkbox_item_state Item iItem to True Set select_state Item iItem to sVal End Else Begin Get FieldSkip of aFields iRow to sVal Send Add_item msg_none "" Get item_count to iItem Decrement iItem Set checkbox_item_state Item iItem to True Set select_state Item iItem to sVal Get FieldLength of aFields iRow to sVal Send Add_item msg_none sVal End Loop Set dynamic_update_state to iOldState End_Procedure // DoFillGrid Procedure OnChange Integer iNewItem String sValue Integer iFieldnumber iCol iRow iValue Boolean bFixed Get Value iNewItem to sValue // value of changed cell Get Line_size to iRow Move (iNewItem / iRow) to iFieldNumber Increment iFieldNumber Get Current_col to iCol Get pbTextFormatIsFixedLength to bFixed If (bFixed = False) Begin Case Begin Case (iCol = 0) If (sValue = "") Move ("Field"+String(iFieldNumber)) to sValue Set Fieldname of aFields iFieldnumber to sValue Case Break Case (iCol = 1) Get FieldTypeToInteger of aFields sValue to iValue Set Fieldtype of aFields iFieldnumber to iValue Case Break Case (iCol = 2) Get select_state Item iNewItem to sValue Set FieldSkip of aFields iFieldnumber to sValue Case Break Case (iCol = 3) Set FieldLength of aFields iFieldnumber to sValue Case Break Case End End Else Begin Case Begin Case (iCol = 0) If (sValue = "") Move ("Field"+String(iFieldNumber)) to sValue Set Fieldname of aFields iFieldnumber to sValue Case Break Case (iCol = 1) Get FieldTypeToInteger of aFields sValue to iValue Set Fieldtype of aFields iFieldnumber to iValue Case Break Case (iCol = 2) Set FieldStart of aFields iFieldnumber to sValue Case Break Case (iCol = 3) Set FieldLength of aFields iFieldnumber to sValue Case Break Case (iCol = 4) Get select_state Item iNewItem to sValue Set FieldSkip of aFields iFieldnumber to sValue Case Break Case End End End_Procedure // OnChange //Procedure Set Select_state Integer iItem Integer bSelected // Forward Set select_state iItem To bSelected // Send OnChange iItem //End_Procedure Procedure Select_Toggling Integer iItm Integer bState Forward Send Select_toggling iItm bState Get current_item to iItm Send OnChange iItm End_Procedure Procedure OnInitSpin Set minimum_position to 0 Set Maximum_position to 2 End_Procedure Procedure Set Spin_Value Integer itm String sVal Integer iCell Get current_item to iCell Get FieldTypeToString of aFields itm to sVal Set Value Item iCell to sVal End_Procedure Function Spin_Value Returns Integer Local String sval local Integer rval iItm Get current_item to iItm Get Value Item iItm to sval Get FieldTypeToInteger of aFields sval to rval Function_Return rval End_Function //AB-StoreEnd End_Object // oFields Object oTextBox2 is a Textbox Set Label to "Fields:" Set Location to 2 3 Set Size to 10 21 Set TypeFace to "MS Sans Serif" End_Object // oTextBox2 Object oFldAdd_bn is a Button Set Label to "Add" Set Location to 90 30 //AB-StoreStart Procedure OnClick Boolean bFixed Integer iMax Get pbTextFormatIsFixedLength to bFixed If (bFixed) Begin Get NumberOfFields of aFields to iMax Increment iMax Send DoFormatFieldList of aFields iMax Set FieldName of aFields iMax to ("Field"+String(iMax)) Send Preload_file End End_Procedure // OnClick //AB-StoreEnd End_Object // oFldAdd_bn Object oFldInsert_bn is a Button Set Label to "Insert" Set Location to 90 110 //AB-StoreStart Procedure OnClick Boolean bFixed Integer iMax iRow iFieldNumber iFromField iNewItem Get pbTextFormatIsFixedLength to bFixed If (bFixed) Begin Get Line_size of oFields to iRow Get Current_Item of oFields to iNewItem Move (iNewItem / iRow) to iFieldNumber Increment iFieldNumber Get NumberOfFields of aFields to iFromField While (iFromField >= iFieldNumber) Send CopyField of aFields iFromField (iFromField + 1) Decrement iFromField Loop Set FieldName of aFields iFieldNumber to ("Field"+String(iFieldNumber)) Set FieldType of aFields iFieldNumber to C_TEXTFIELDTYPE_ASCII Set FieldStart of aFields iFieldNumber to 0 Set FieldLength of aFields iFieldNumber to 50 Set FieldSkip of aFields iFieldNumber to False Send Preload_file End End_Procedure // OnClick //AB-StoreEnd End_Object // oFldInsert_bn Object oFldDelete is a Button Set Label to "Delete" Set Location to 90 190 //AB-StoreStart Procedure OnClick Boolean bFixed Integer iMax iRow iFieldNumber iFromField iNewItem Get pbTextFormatIsFixedLength to bFixed If (bFixed) Begin Get Line_size of oFields to iRow Get Current_Item of oFields to iNewItem Move (iNewItem / iRow) to iFieldNumber Increment iFieldNumber Move iFieldNumber to iFromField Get NumberOfFields of aFields to iMax While (iFromField < iMax) Send CopyField of aFields (iFromField + 1) iFromField Increment iFromField Loop Decrement iMax Send DoFormatFieldList of aFields iMax // Deletes last row Send Preload_file End End_Procedure // OnClick //AB-StoreEnd End_Object // oFldDelete End_Object // oCntFields Object oRefresh_bn is a Button Set Label to "Refresh" Set Location to 272 349 //AB-StoreStart Procedure OnClick Send Preload_file End_Procedure // OnClick //AB-StoreEnd End_Object // oRefresh_bn Object oSave is a Button Set Label to "Save definition" Set Size to 14 61 Set Location to 271 6 //AB-StoreStart // fires when the button is clicked //Procedure OnClick // String sImportFile sFilename sDir sImportDefFile // Boolean bOk bSaveOk // Set psImportFile to sImportFile // Get ExtractFilePath sImportFile to sDir // Get vFolderFormat sDir to sDir // Get ExtractFileName sImportFile to sFilename // Move (sFilename + ".AID") to sImportDefFile // Set File_title of oSaveAsDialog to sImportDefFile // Get Show_Dialog of oSaveAsDialog to bSaveOk // If (bSaveOk = True) Begin // Get File_name of oSaveAsDialog to sImportDefFile // Send DoSaveDefinitionFile sImportDefFile // End //End_Procedure // OnClick // Not yet ready. Set visible_state to False Set enabled_state to False //AB-StoreEnd End_Object // oSave Object oLoad is a Button Set Label to "Load definition" Set Size to 14 61 Set Location to 271 71 //AB-StoreStart // fires when the button is clicked //Procedure OnClick //End_Procedure // OnClick // Not yet ready. Set visible_state to False Set enabled_state to False //AB-StoreEnd End_Object // oLoad Object oSaveAsDialog is a SaveAsDialog //AB/ Set Location to 266 138 Set AllowReadOnly_State to FALSE Set CreatePrompt_State to FALSE Set Dialog_Caption to "Save AnyFlex Import Definition File" Set FileMustExist_State to FALSE Set File_Title to "hhhh" Set Filter_String to "AnyFlex Import Definition Files (*.aid)|*.aid" Set HideReadOnly_State to TRUE //AB-StoreStart //Class is defined in File_dlg.Pkg //Show_Dialog is a predefined function in the SaveAsDialog class. //Call the OpenDialog via: //get Show_Dialog to iIntegerVariable // //DoCallSaveAsDialog is NOT a predefined method in the SaveAsDialog class. //DoCallSaveAsDialog is just a code sample. //You can call DoCallSaveAsDialog from another object, such as a button. // //Procedure DoCallSaveAsDialog // Boolean bOk // // Get Show_Dialog To bOk // If (bOk) Begin // // // End //End_Procedure // DoCallSaveAsDialog //AB-StoreEnd End_Object // oSaveAsDialog //AB-StoreStart On_Key kCancel Send KeyAction of oCancel_btn Procedure activate_group Integer iNumberOfFields Forward Send activate_group Send Delete_data of oFields Send Delete_data of aFields Send Delete_Data of oData // *** CHANGE DEFAULT VALUE HERE! *** Set value of oFieldSeperator Item 0 to "," Set psFieldSeperator to "," Set value of oText Item 0 to '"' Set psTextQualification to '"' Set Value of oDateSeperator Item 0 to "-" // European format Set psDateSeperator to "-" Set value of oDateFormat Item 0 to "DD-MM-YYYY" // European format Set psDateFormat to "DD-MM-YYYY" Set value of oDecimalsign Item 0 to "," // European format Set psDecimalSign to "," // *** *** Set Current_Radio of oTextFormat to 1 Get NumberOfFields of aFields to iNumberOfFields If (iNumberOfFields = 0) Send Preload_file // Current_radio was already set to 1 End_Procedure Procedure Preload_file Integer iMaxFields iDataRowCount iType Integer iOldState iField Boolean bFirst bFixed bOk String sFieldname Number nLength Get dynamic_update_state of oData to iOldState Set dynamic_update_state of oData to False Get pbTextFormatIsFixedLength to bFixed Move 0 to iDataRowCount Get OpenTextFile to bOk If bOk Begin Get ReadTextFile to bOk If bOk Begin Get pbFirstRowIsFieldNames to bFirst If (bFirst) Begin If (bFixed = False) Begin Get NumberOfFieldsFromRecord to iMaxFields Send DoFormatFieldList of aFields iMaxFields End Else Begin Get NumberOfFields of aFields to iMaxFields If (iMaxFields = 0) Send DoFormatFieldList of aFields 1 End For iField From 1 to iMaxFields Get FieldName of aFields iField to sFieldname Move (Uppercase(Left(sFieldname,5))) to sFieldname If (sFieldname = "FIELD" or sFieldname = "") Begin Get DataFromField iField C_TEXTFIELDTYPE_ASCII to sFieldname If (sFieldname = "") Move ("Field"+String(iField)) to sFieldname Set FieldName of aFields iField to sFieldname End If (bFixed = False) Begin Get FieldLength of aFields iField to nLength Get FieldType of aFields iField to iType If (iType = C_TEXTFIELDTYPE_ASCII) Begin If (nLength = 0) Move 50 to nLength End If (iType = C_TEXTFIELDTYPE_NUMERIC) Begin If (nLength > 14.8) Move 14.8 to nLength If (nLength = 0) Move 10.4 to nLength End Set FieldLength of aFields iField to nLength End Loop Send DoFillGrid of oFields Send DoInitialiseGrid of oData End Else Begin If (bFixed = False) Begin Get NumberOfFieldsFromRecord to iMaxFields Send DoFormatFieldList of aFields iMaxFields End Else Begin Get NumberOfFields of aFields to iMaxFields If (iMaxFields = 0) Send DoFormatFieldList of aFields 1 End Send DoFillGrid of oFields Send DoInitialiseGrid of oData Send DoShowData of oData Increment iDataRowCount End Get ReadTextFile to bOk While (iDataRowCount < 50 and bOk = True) Send DoShowData of oData Increment iDataRowCount Get ReadTextFile to bOk Loop End Send CloseTextFile End Set dynamic_update_state of oData to iOldState End_Procedure Procedure DoSaveDefinitionFile String sDefFile // Integer iFilenr // If (sDefFile = "") Procedure_Return // Get Seq_New_Channel to iFilenr // Direct_Output Channel iFilnr sDefFile ////Property String psImportFile Public "" ////Property String psRecord Public "" ////Property String psFieldSeperator Public "," ////Property String psTextQualification Public '"' ////Property String psDateFormat Public "" ////Property String psDateSeperator Public "" ////Property Boolean pbFourDigitYear Public True ////Property String psDecimalSign Public "" ////Property Boolean pbToOEM Public True ////Property Boolean pbFirstRowIsFieldNames Public False ////Property Boolean pbTextFormatIsFixedLength Public False ////Property Integer piCurrentFilenumber Public 0 ////Property String psDFDecimalSeperator Public "" ////Property String psDFDateSeperator Public "" // Close_Output Channel iFilnr // Send Seq_Release_Channel iFilnr End_Procedure //AB-StoreEnd End_Object // Import_textfile //AB/ End_Object // prj