//AB/ Project Edit databasefile //AB/ Object prj is a View_Project //AB/ Set Size to 311 613 //AB/ Set ProjectName to "Edit databasefile" //AB/ Set ProjectFileName to "anyflex.vw" // Project Object Structure // tilpas_vw is a dbView // cntFil is a Container3d // filStdreg is a Form // cmbIndex is a ComboForm // oFilelist_bn is a Button // oWorkspace_bn is a Button // cntStatus is a Container3d // filRecords is a Form // oMaxRecords is a Form // oTxt1 is a Textbox // oBox is a dbContainer3d // oData is a dbGrid // anyMenu is a FloatingPopupMenu // Element is a CM_EntryList // Element is a CM_EntryList (Duplicate object name) // oRecordContents is a array // Register all objects Register_Object anyMenu Register_Object cmbIndex Register_Object cntFil Register_Object cntStatus Register_Object Element Register_Object filRecords Register_Object filStdreg Register_Object oBox Register_Object oData Register_Object oFilelist_bn Register_Object oMaxRecords Register_Object oRecordContents Register_Object oTxt1 Register_Object oWorkspace_bn Register_Object tilpas_vw //AB-StoreTopStart Use Anyflex.dd Use Retxt.dg Use Editer_record.dg Use Shell_Extentions.dg Use Brug_Filelist.sl Use Kopier_Fra_Database.dg Use Global.dg Use Filtersetup.dg Use RefreshTimer.dg Use EditIndexes.dg Use Copy_from_file.dg Use FindText.dg Use FillValue.dg Use Columnfilter.dg #IFDEF WithColumnProperties Use Columnprops.dg #ENDIF Use ModifyFilelist.dg Register_Object oStatusbar Register_Procedure DoShowOpenPathHelp //AB-StoreTopEnd //AB-IgnoreStart Use dfClient.pkg Use Windows.pkg Use dfCmbFrm.pkg Use dfTable.pkg //AB-IgnoreEnd ACTIVATE_VIEW Activate_tilpas_vw FOR tilpas_vw Object tilpas_vw is a dbView //AB-StoreTopStart Enum_List Define CONV_TO_ANSI For 1 Define CONV_TO_OEM Define C_WITH_POPUP Define C_WITHOUT_POPUP End_Enum_List Property Integer er_aktiveret Public 0 Property Boolean pbFullViewMode Public False Property Integer piGridDDObj Public 0 Function BeskrivFelttype Integer felttype Returns String Local String besked If (Felttype = DF_ASCII) Move "ASCII" to Besked If (Felttype = DF_BCD) Move "NUMERIC" to Besked If (Felttype = DF_DATE) Move "DATE" to Besked If (Felttype = DF_TEXT) Move "TEXT" to Besked If (Felttype = DF_BINARY) Move "BINARY" to Besked If (Felttype = DF_OVERLAP) Move "OVERLAP" to Besked Function_Return besked End_Function Function ErFeltType String sFelttype Returns Integer Integer iFelttype If (sFelttype = "ASCII") Move DF_ASCII to iFelttype If (sFelttype = "NUMERIC") Move DF_BCD to iFelttype If (sFelttype = "DATE") Move DF_DATE to iFelttype If (sFelttype = "TEXT") Move DF_TEXT to iFelttype If (sFelttype = "BINARY") Move DF_BINARY to iFelttype If (sFelttype = "OVERLAP") Move DF_OVERLAP to iFelttype Function_Return iFelttype End_Function Function MakeTempFilelist Returns String Integer iRetval iError iFilenr iCnt String sTempPath sTempFileName sBuffer Pointer lpTempPath Move (Repeat (Character (0), 255)) to sTempPath GetAddress of sTempPath to lpTempPath Move (vWin32_GetTempPath (255, lpTempPath)) to iRetVal If (iRetVal = 0) Begin Get ShowLastError to iError Function_Return "" End Move (Left(sTempPath, iRetVal)) to sTempPath Get vFolderFormat sTempPath to sTempPath Move (sTempPath+"Anyflex.cfg") to sTempFilename Move (Repeat(Character(0), 1024)) to sBuffer Get Seq_New_Channel to iFilenr Direct_Output Channel iFilenr sTempFilename Write Channel iFilenr "filelist.cfg" (Repeat(Character(0), 1012)) For iCnt From 1 to 511 Write Channel iFilenr sBuffer Loop Close_Output Channel iFilenr Send Seq_Release_Channel iFilenr Function_Return sTempFileName End_Function // vMakeTempFile //AB-StoreTopEnd Set Border_Style to Border_Thick Set Caption_Bar to FALSE Set Minimize_Icon to FALSE Set Label to "Edit databasefile" Set Location to 6 6 Set Size to 226 456 Set piMinSize to 50 250 Set Auto_Clear_DEO_State to FALSE //AB-DDOStart //AB-DDOEnd Object cntFil is a Container3d Set Size to 32 329 Set Location to 0 1 Set peAnchors to anTopLeftRight Object filStdreg is a Form Set Label to "Filename:" Set Size to 13 242 Set Location to 1 37 Set peAnchors to anTopLeftRight Set Label_Col_Offset to 35 Set Prompt_Button_Mode to pb_PromptOn //AB-StoreStart On_Key kEnter Send DoOpenThisFile Procedure Prompt String sInitDir sValgtFil Integer iPos Boolean bFound // Set init directory to current file. // If no file specified set working directory as ..\Data from this instance. If (not(pFilOk(Self))) Begin Move (SysConf(sysconf_runtime_name)) to sInitDir Get ExtractFilePath sInitDir to sInitDir If (Right(sInitDir, 1) = "\") Move (Left(sInitDir, (Length(sInitDir) - 1))) to sInitDir Get LastDelimeter "\:" sInitDir to iPos If (iPos) Begin Move (Left(sInitDir, iPos)) to sInitDir Get FileExists (sInitDir+"Data") DIRMODE_DIRECTORIES_ONLY to bFound If (bFound) Append sInitDir "Data" End End Else Begin Get psFilename to sValgtFil Get ExtractFilePath sValgtFil to sInitDir End Move (vSelect_File("Datafiles (*.dat;*.int)|*.dat;*.int|Dataflex file (*.dat)|*.dat|Driverbased files (*.int)|*.int", "Choose file", sInitDir)) to sValgtFil If (Trim(sValgtFil) <> "") Begin Set value to sValgtFil Send DoOpenThisFile End End_Procedure Procedure DoOpenThisFile String sValgtFil Get value to sValgtFil Set piFileNumber to 0 Set psFilename to sValgtFil Send DoUndersoegFil End_Procedure //AB-StoreEnd End_Object // filStdreg Object cmbIndex is a ComboForm Set Label to "Index:" Set Size to 13 242 Set Location to 15 37 Set peAnchors to anTopLeftRight Set Form_Border to 0 Set Label_Col_Offset to 35 Set Entry_State Item 0 to FALSE //AB-StoreStart Procedure Combo_Fill_List Integer AntalIndex aktIndex antalSegmenter aktSegment Feltnr iVal String sBesked strTemp Integer iFile iStartIndexnumber Handle hDDObj Get piFileNumber to iFile Get piGridDDObj to hDDObj Send Combo_delete_data Get FirstIndexNumber to iStartIndexnumber Set ordering of oData to iStartIndexnumber If (hDDObj > 0) Set ordering of hDDObj to iStartIndexnumber If (pFilOk(Self)) Begin If (pbRecnumFile(Self) = True) Send Combo_Add_Item "00: No index" 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 iFile (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 End Set pIndexChangeOk to False If (AntalIndex > 0) Set value Item 0 to (Combo_Value(Self, 0)) Set pIndexChangeOk to True End_Procedure Procedure OnChange String sVal Integer iIndex iOk Boolean bDoSave Handle hDDObj Get piGridDDObj to hDDObj Get pIndexChangeOk to iOk If (not(iOk)) Procedure_Return Send Request_clear of oData Get should_save of hDDObj to bDoSave If (bDoSave) Procedure_Return Send activate of oData Get value Item 0 to sVal Left sVal to iIndex 2 Set ordering of oData to iIndex Set ordering of hDDObj to iIndex Send DoPaintTheList End_Procedure //AB-StoreEnd End_Object // cmbIndex Object oFilelist_bn is a Button Set Label to "File&list" Set Size to 14 43 Set Location to 1 281 Set peAnchors to anRight //AB-StoreStart Set enabled_state to False Procedure OnClick String sFile Boolean bWorkSpace Send popup to Brug_Filelist Get psValgtReg of Brug_Filelist to sFile If (sFile = "") Procedure_Return Set psFilename to sFile Send DoUndersoegFil End_Procedure // OnClick //AB-StoreEnd End_Object // oFilelist_bn Object oWorkspace_bn is a Button Set Label to "&Workspace" Set Size to 14 43 Set Location to 15 281 Set peAnchors to anRight //AB-StoreStart // Set enabled_state To False // Old version that uses SelectWorkspace dialog. //Procedure OnClick // Boolean bNewWorkspace // String sWorkspace sFilelist // Get SelectWorkspace of oSelectWorkspace to bNewWorkspace // If (bNewWorkspace = False) Procedure_Return // Send DoClearView // Get psWorkspaceSelected of oSelectWorkspace to sWorkspace // Send DoOpenWorkspace of oApplication sWorkspace // Get_Attribute DF_FILELIST_NAME to sFilelist // Set enabled_state of oFilelist_bn to True // Set pFundetFilelist to sFilelist //End_Procedure // OnClick Procedure OnClick Handle hoWorkspace Boolean bFileSelected String sWorkspaceFile sError Integer iFejl Get phoWorkspace of ghoApplication to hoWorkspace Move (vSelect_File("Workspace Files (*.ws)|*.ws", "Choose workspace file", "")) to sWorkspaceFile If (sWorkspaceFile <> "") Begin Send DoClearView Send DoClearPaths of hoWorkspace Get OpenWorkspaceFile of hoWorkspace sWorkspaceFile to iFejl If (iFejl <> wsWorkspaceOpened) Begin Get OpenWorkspaceErrorMessage of hoWorkspace iFejl to sError Send Stop_Box sError "Error Opening Workspace" End Else Begin Set enabled_state of oFilelist_bn to True Send DoShowOpenPathHelp Set pbFilelistUsed to True End End End_Procedure // OnClick //AB-StoreEnd End_Object // oWorkspace_bn End_Object // cntFil Object cntStatus is a Container3d Set Size to 32 121 Set Location to 0 331 Set peAnchors to anTopRight Object filRecords is a Form Set Label to "Records:" Set Size to 13 80 Set Location to 1 37 Set peAnchors to anTopRight Set Label_Col_Offset to 35 //AB-StoreStart Set enabled_state to False Set Value Item 0 to "No file opened." Procedure Set value Integer Item# String val Handle hDDObj Boolean bFilterActive If (pSystemfile(Self)) Append val " (systemfile)" Get piGridDDObj to hDDObj If (hDDObj) Get pbFilterActive of hDDObj to bFilterActive If (bFilterActive) Move "(filter active)" to val Forward Set value Item Item# to Val End_Procedure //AB-StoreEnd End_Object // filRecords Object oMaxRecords is a Form Set Label to "Filesize:" Set Size to 13 80 Set Location to 15 37 Set Label_Col_Offset to 35 Set Form_DataType to ascii_window //AB-StoreStart On_Key key_F2 Send DoRetFilesize //Procedure OnChange // String sValue // Get value to sValue // //End_Procedure // OnChange Set enabled_state to False Set Value Item 0 to "No file opened." Procedure Set value Integer Item# String val If (pSystemfile(Self)) Append val " (systemfile)" Forward Set value Item Item# to Val End_Procedure Procedure DoRetFilesize String sValgtFil Integer iNyMaxRec StructHandle iFile iFile2 Get piFileNumber to iFile2 // Send DoShowWorking "Resetting filesize." Get psFilename to sValgtFil If (sValgtFil = "") Procedure_Return Get NextFreeFilenumber iFile2 to iFile If (iFile = 0) Procedure_Return Get value to iNyMaxRec Send DoCloseAllFiles Open sValgtFil as iFile Mode DF_EXCLUSIVE If (Found) Begin Send activate to resinfo Move iFile to StructHandle Structure_Start StructHandle Set_Attribute DF_FILE_MAX_RECORDS of StructHandle to iNyMaxRec Structure_End StructHandle DF_STRUCTEND_OPT_NONE "" (resinfo(Self)) Send Close_panel to resinfo End Close iFile Send DoUndersoegFil // Send DoLukInfopanel End_Procedure //AB-StoreEnd End_Object // oMaxRecords End_Object // cntStatus Object oTxt1 is a Textbox Set Location to 1 1 Set Size to 2 1 Set FontWeight to 700 Set TypeFace to "MS Sans Serif" //AB-StoreStart Set visible_state to False //AB-StoreEnd End_Object // oTxt1 Object oBox is a dbContainer3d Set Size to 189 451 Set Location to 33 0 Set peAnchors to anAll Object oData is a dbGrid //AB-StoreTopStart Object anyMenu is a FloatingPopupMenu On_Item "Extention setup\aCtrl+E" Send DoShell_Extentions On_Item "" Send None On_Item "Choose field from searchlist\aCtrl+S" Send DoGotoField On_Item "Edit indexes\aCtrl+I" Send DoEditIndexes On_Item "Reindex all indexes\aCtrl+R" Send DoReindexAll On_Item "Zerofile - Delete all records\aCtrl+Delete" Send DoZerofile On_Item "" Send None On_Item "Choose fields to show\aCtrl+L" Send DoColumnFilter On_Item "Shift current column to the right\aCtrl+Tab" Send DoShiftColumnToRight On_Item "Shift current column to the left\aCtrl+Shift+Tab" Send DoShiftColumnToLeft On_Item "" Send None On_Item "Copy from database to database\aCtrl+K" Send DoKopier_Fra_Database On_Item "Import from textfile\aCtrl+T" Send DoCopyFromFile On_Item "" Send None On_Item "Vdfquery\aCtrl+P" Send DoActivateQuery On_Item "Global Data Replacement Utility\aCtrl+G" Send DoGlobalUtility On_Item "New instance with current record\aCtrl+N" Send DoNewInstance On_Item "" Send None On_Item "Fill current column\aCtrl+U" Send DoFillCurrentColumn On_Item "Convert column from ANSI to OEM" Send DoConvertColumnAnsiToOem On_Item "Convert column from OEM to ANSI" Send DoConvertColumnOemToAnsi On_Item "Delete all rows of current filters" Send DoDeleteAllRows On_Item "" Send None On_Item "Toggle filter active\aAlt+F" Send DoToogleFilterActive On_Item "Filter setup\aCtrl+F" Send DoFilterSetup On_Item "Count filter records\aCtrl+D" Send DoCountFilterRecords On_Item "Clear all filters\aCtrl+Q" Send DoClearFilters On_Item "Make filter for current value\aEnter" Send DoMakeFilter On_Item "" Send None On_Item "Toggle full view\aCtrl+W" Send DoToggleFullView On_Item "Autorefresh timer\aCtrl+A" Send DoAutoRefresh On_Item "Refresh screen manually\aShift+F5" Send DoPageRefresh On_Item "" Send None On_Item "Edit text\aF4" Send DoEditText On_Item "Edit record in zoom view\aF12" Send DoShowRecordView On_Item "" Send None On_Item "Free Text Search" Send DoTextSearch On_Item "Find next text\aF3" Send DoFindNextText On_Item "" Send None On_Item "Modify current filelist\aCtrl+B" Send DoModifyFilelist #IFDEF WithColumnProperties On_Item "" Send None On_Item "Modify column properties\aCtrl+M" Send DoColumnProperties #ENDIF On_Item "" Send None On_Item "Help\aF1" Send DoHelp On_Item "About\aCtrl+F1" Send Activate_About End_Object //AB-StoreTopEnd Set Size to 184 446 Set Location to 1 1 Set CurrentRowColor to 16506583 Set CurrentCellColor to 14667984 Set peAnchors to anAll Set peResizeColumn to rcNone Set pbHeaderTogglesDirection to TRUE Set Wrap_State to TRUE Set psEmbeddedButtonValue to "" Set Prompt_Button_Mode to pb_PromptOff //AB-StoreStart If (Element(Self)) Send Destroy of Element Set floating_menu_object to (AnyMenu(current_object)) Set verify_Delete_msg to get_no_confirmation Set enabled_State to False On_Key Key_Ctrl+Key_Delete Send DoZerofile On_Key Key_Ctrl+Key_A Send DoAutoRefresh On_Key Key_Ctrl+Key_B Send DoModifyFilelist On_Key Key_Ctrl+Key_D Send DoCountFilterRecords On_Key Key_Ctrl+Key_E Send DoShell_Extentions On_Key Key_Ctrl+Key_F Send DoFilterSetup On_Key Key_Ctrl+Key_G Send DoGlobalUtility On_Key Key_Ctrl+Key_I Send DoEditIndexes On_Key Key_Ctrl+Key_K Send DoKopier_Fra_Database On_Key Key_Ctrl+Key_L Send DoColumnFilter #IFDEF WithColumnProperties On_Key Key_Ctrl+Key_M Send DoColumnProperties #ENDIF On_Key Key_Ctrl+Key_P Send DoActivateQuery On_Key Key_Ctrl+Key_Q Send DoClearFilters On_Key Key_Ctrl+Key_R Send DoReindexAll On_Key Key_Ctrl+Key_S Send DoGotoField On_Key Key_Ctrl+Key_T Send DoCopyFromFile On_Key Key_Ctrl+Key_U Send DoFillCurrentColumn On_Key Key_Ctrl+Key_W Send DoToggleFullView On_Key Key_F12 Send DoShowRecordView On_Key kEnter Send DoMakeFilter On_Key Key_F3 Send DoFindNextText On_Key Key_Ctrl+Key_Tab Send DoShiftColumnToRight On_Key 7170 Send DoShiftColumnToLeft // CTRL + SHIFT + TAB On_Key KRefresh_Screen Send DoPageRefresh // SHIFT+F5 On_Key Key_Alt+Key_F Send DoToogleFilterActive //Procedure Key Integer iKeyValue Returns Integer // Integer iRetVal // Showln "Key: " iKeyValue // Forward Get Msg_Key iKeyValue To iRetVal // Procedure_Return iRetVal //End_Procedure // This object is only for use of the grid while it is empty at program start. // Thereafter it will be deleted. Object Element is a CM_EntryList Set Focus_Mode to NonFocusable Function Item_Entry_Msg Integer iItem Returns Integer Integer iMsg iMaxItems Get Item_count to iMaxItems If (iItem >= iMaxItems) Function_Return 0 Forward Get Item_Entry_Msg Item iItem to iMsg End_Function End_Object /*** The following procedures And functions are argumented To make the // dbGrid a dynamic dbGrid. Procedure vFind_Init Integer File# Integer ordr# Integer Dir If (File# = 0) Procedure_Return Forward Send vFind_Init End_Procedure Procedure vClear Integer File# If (File# = 0) Procedure_Return Forward Send vClear File# End_Procedure Procedure vFind_Rec Integer File# Integer Ordr# Integer Mode If (File# = 0) Procedure_Return Forward Send vFind_Rec File# Ordr# Mode End_Procedure Procedure Set top_item Integer iNewTop Integer iMaxItems iDummy Get item_count to iMaxItems If (iNewTop >= iMaxItems) Procedure_Return Forward Set top_item to iNewTop End_Procedure Procedure vRead_rec Integer File# Integer rec# If (File# = 0) Procedure_Return Forward Send vRead_rec File# rec# End_Procedure Procedure Fill_Page Integer Row# Integer Col# Integer iFile Get main_file to iFile If (iFile = 0) Procedure_Return Forward Send Fill_Page Row# Col# End_Procedure Procedure Entry_Display Integer iFile Integer iFlag Integer iMaxItems Get Item_Count to iMaxItems If (iMaxItems = 0) Procedure_Return Forward Send Entry_Display iFile iFlag End_Procedure Procedure Set GuiSize Integer row Integer col // Needed check for Vista Integer iMaxItems Get Item_count to iMaxItems If (iMaxItems <> 0) Forward Set GuiSize to row col End_Procedure // set guisize // */ Procedure DoCreateGrid Boolean bDoReorder Integer iShowColumn Integer iItems iItem hoFieldList iField iFieldType iFieldLength Integer iColumn iColumns iDecimals iElementItem Integer iFileField iDisplayableRows iTotalWidth iFormWidth iAntalFelter Integer iFile iOldState lcif rcif iWidth iOffs iColumnFilter Integer iStartField iStartIndexnumber Boolean bSelected String sFieldName sBeskriv sMask Handle hoServer hDDObj hOldDD Get piFileNumber to iFile Get dynamic_update_state to iOldState Set dynamic_update_state to False Send DoMakeColumnVisible 0 // Prevents a GPF. Set piGridDDObj to hOldDD If (hOldDD > 0) Begin Send remove_deo_from_server Send Destroy of hOldDD End Set piGridDDObj to 0 Get FirstIndexNumber to iStartIndexnumber Set main_file to 0 Set ordering to iStartIndexnumber If (Element(Self) <> 0) Send destroy to (Element(Self)) Send Delete_data Set Item_Limit to 1 Set Line_Width to 0 (Displayable_rows(Self)) Set Matrix_Size to 0 (Displayable_rows(Self)) Clear iFile Get Create U_Anyflex_DataDictionary to hDDObj Set piGridDDObj to hDDObj Set main_file of hDDObj to iFile Set main_file to iFile Set Main_DD of tilpas_vw to hDDObj Set Server of tilpas_vw to hDDObj Set Ordering of hDDObj to iStartIndexnumber Get item_count of aColumnFilters to iColumnFilter If (iColumnFilter = 0) Get pDataNumFields to iAntalFelter Else Begin Move iColumnFilter to iAntalFelter Decrement iAntalFelter End Get FirstFieldnumber to iStartField If (iColumnFilter > 0) Move 0 to iStartField Object Element is a CM_EntryList Set Focus_Mode to NonFocusable For iItem From iStartField to iAntalFelter Entry$Item |FN0,0 Move (Item_Count (Self) - 1) to iElementItem If (iColumnFilter > 0) Get integer_value of aColumnFilters Item iItem to iField Else Move iItem to iField Set Data_File Item iElementItem to iFile Set Data_Field Item iElementItem to iField Loop Move (Item_Count (Self)) to iColumns End_Object Get Displayable_Rows to iDisplayableRows Set Item_Limit to iColumns Set Line_Width to iColumns iDisplayableRows Set Matrix_Size to iColumns iDisplayableRows Move 0 to iColumn For iItem From iStartField to iAntalFelter Get Data_Field of Element Item iColumn to iField Get String_value of aFilDef Item (iField * 4) to sFieldname Get integer_value of aFildef Item ((iField * 4) + 2) to iFieldLength Get integer_value of aFildef Item ((iField * 4) + 1) to iFieldType Move "Field: " to sBeskriv Append sBeskriv (String(iField)) " Type: " Append sBeskriv (beskrivFelttype(Self, iFieldType)) Append sBeskriv ", " iFieldLength Case Begin Case (iFieldType = DF_DATE) Set Form_Datatype Item iColumn to DATE_WINDOW Move 10 to iFieldLength Case Break Case (iFieldType = DF_BCD) Get integer_value of aFilDef Item ((iField * 4) + 3) to iDecimals Calc (iFieldLength - iDecimals) to lcif Move iDecimals to rcif Append sBeskriv " (" lcif "," rcif ")" Set Header_Justification_Mode Item iColumn to jMode_Right Set Form_Datatype Item iColumn to mask_numeric_window //iDecimals Move (maske(Self, lcif, rcif)) to sMask Set form_mask Item iColumn to sMask Case Break Case (iFieldType = DF_ASCII) Set Form_Datatype Item iColumn to ASCII_WINDOW Set form_margin Item iColumn to iFieldLength Set Header_Justification_Mode Item iColumn to jMode_Left Case Break Case (iFieldType = DF_TEXT) Set Form_Datatype Item iColumn to ASCII_WINDOW Set Column_Button Item iColumn to Form_Button_Prompt Set Form_button_value Item iColumn to "Edit" Case Break Case (iFieldType = DF_OVERLAP) Set Form_Datatype Item iColumn to ASCII_WINDOW Set column_shadow_state iColumn to True Case Break Case End Set Header_Label Item iColumn to sFieldName Set status_help Item iColumn to sBeskriv Set label of oTxt1 to ("M"+sFieldname) Get GuiSize of oTxt1 to iOffs Move (Low(iOffs)) to lCif If (iFieldType <> DF_TEXT) Set label of oTxt1 to (Repeat("n", iFieldLength)) Get Guisize of oTxt1 to iOffs Move (Low(iOffs)) to rCif If (lCif > rCif) Move lCif to rCif Move rCif to iWidth If (iWidth > 300) Move 300 to iWidth // Max initial size of columns Set form_Guiwidth Item iColumn to iWidth Increment iColumn Loop Set server to hDDObj If (bDoReorder = True) Send OnChange of cmbIndex Set read_only_state to False Set enabled_State to True Send DoMakeColumnVisible iShowColumn Set current_item to iShowColumn Set dynamic_update_state to iOldState End_Procedure // DoCreateGrid Procedure DoGotoField Integer iPopupMode String sValgtFil sValgtFelt sTest Integer iFundet iItem iBaseItem iColumns Integer iFile iStartField iMode iField If (not(pFilOk(Self))) Procedure_Return Get piFileNumber to iFile If (Num_arguments > 0) Move iPopupMode to iMode Else Move C_WITH_POPUP to iMode If (iMode = C_WITH_POPUP) Send popup of oChooseField Get pValgtFelt to sValgtFelt If (sValgtFelt <> "") Begin Move -1 to iFundet Move 0 to iItem Get item_count of aColumnFilters to iColumns If (iColumns = 0) Get pDataNumFields to iColumns While (iFundet = -1 and iItem < iColumns) Get Data_field Item iItem to iField Get String_value of aFilDef Item (iField * 4) to sTest If (sTest = sValgtFelt) Move iItem to iFundet Increment iItem Loop If (iFundet > -1) Begin Get base_item to ibaseItem Set current_item to (iBaseItem + iFundet) End End End_Procedure Procedure Refresh Integer iMode Forward Send Refresh iMode Send DumpRecordsUsed End_Procedure // Disable ESC key in grid. Function verify_Exit Returns Integer Function_Return 1 End_Function Procedure DoMakeFilter Integer iItem iCol iFilterItems iField iMode String sFieldname sValue sMode Handle hDDObj tsFilter[] lsFilter Get current_item to iItem Get current_col to iCol Get piGridDDObj to hDDObj Get plsFilter of hDDObj to lsFilter Move (SizeOfArray(lsFilter)) to iFilterItems Get Data_field Item iItem to iField Get String_value of aFilDef Item (iField * 4) to sFieldname Get value Item iItem to sValue Set label of (oRadioGroup1(oMode(Self))) to ("Mode on "+sFieldname+" for {"+sValue+"}") Send popup of oMode Set label of (oRadioGroup1(oMode(Self))) to "Mode" Get piSelectedMode of oMode to iMode If (iMode = -1) Procedure_Return Get FilterMode iMode to sMode Move sFieldname to lsFilter[iFilterItems].sField Move sMode to lsFilter[iFilterItems].sMode Move sValue to lsFilter[iFilterItems].sValue Set plsFilter of hDDObj to lsFilter Set pbFilterActive of hDDObj to True Send DoPaintTheList End_Procedure // Activate or deactivate the current filter. Procedure DoToogleFilterActive Handle hDDObj Boolean bValue If (not(pFilOk(Self))) Procedure_Return Get piGridDDObj to hDDObj Get pbFilterActive of hDDObj to bValue Set pbFilterActive of hDDObj to (not(bValue)) Send DoPaintTheList End_Procedure Procedure DoShowRecordView Integer iAktRk iAntalFelter iAktItem aktpos iAktRecord Integer iFile iStartField RowID rwCurrentRecord String strTemp Handle hDDObj If (not(pFilOk(Self))) Procedure_Return Get piFileNumber to iFile Get pDataNumFields to iAntalFelter Get piGridDDObj to hDDObj If (HasRecord(hDDObj)) Begin Get CurrentRowId to rwCurrentRecord Set prwCurrentRecord of Editer_Record_dg to rwCurrentRecord Send Refind_records of hDDObj Get FirstFieldnumber to iStartField For aktpos From iStartField to iAntalFelter Get_Field_Value iFile aktpos to strTemp Set array_value of (aRecData(Self)) Item (aktpos-1) to (Rtrim(strTemp)) Loop Send fill_the_list to (Editer_record_dg(Self)) Send Popup_Modal to (Editer_record_dg(Self)) End End_Procedure Procedure DoEditText Integer iField feltlng Felttype iItem String sTekst sDelTekst Integer i iLines iFile Handle hEdit hDDObj RowID rwRecord Boolean bFound Get piFileNumber to iFile Get piGridDDObj to hDDObj Get current_item to iItem Get Data_field Item iItem to iField Get integer_value of afildef Item ((iField * 4) + 1) to felttype If (felttype = DF_TEXT) Begin Get CurrentRowId of hDDObj to rwRecord Send Refind_records of hDDObj Get_Field_Value iFile iField to sTekst Get integer_value of aFildef Item ((iField* 4) + 2) to feltlng Move (oText(cntTekst(retxt_dg(Self)))) to hEdit Send delete_data to hEdit Set piMaxChars of hEdit to feltlng Set value of hEdit to sTekst Send Popup_modal to (Retxt_dg(Self)) If (pTekstGem(retxt_dg(Self))) Begin Get value of hEdit to sTekst Clear iFile Move (FindByRowId(iFile, rwRecord)) to bFound Reread iFile Set_Field_Value iFile iField to sTekst Saverecord iFile Unlock Send DoPageRefresh End End End_Procedure // First time - Clear constraints // Second time - Show all columns (Clear column filters) // Otherwise - Rebuild constraints and send beginning_of_data Procedure DoClearFilters Handle hDDObj Integer iMaxItems tsFilter[] lsFilter lsTomFilter Get piGridDDObj to hDDObj If (hDDObj) Begin Get plsFilter of hDDObj to lsFilter Move (SizeOfArray(lsFilter)) to iMaxItems If (iMaxItems > 0) Begin Set plsFilter of hDDObj to lsTomFilter Set pbFilterActive of hDDObj to False Send DoPaintTheList Procedure_Return End End Get item_count of aColumnFilters to iMaxItems If (iMaxItems > 0) Begin Send delete_data of aColumnFilters Send DoCreateGrid True 0 Procedure_Return End Send DoPaintTheList End_Procedure Procedure OnRefreshTimer Boolean bChanged Handle hDDObj If (not(pFilOk(Self))) Procedure_Return Get piGridDDObj to hDDObj Get should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Send refresh_page fill_from_top End_Procedure Procedure DoEditIndexes Boolean bChanged Handle hDDObj Integer iStartIndex If (not(pFilOk(Self))) Procedure_Return Get piGridDDObj to hDDObj Get should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Send popup of EditIndexes Get pbIndexChanged of EditIndexes to bChanged If (bChanged = True) Begin Get FirstIndexNumber to iStartIndex Set ordering to iStartIndex Set ordering of hDDObj to iStartIndex Send DoUndersoegFil End End_Procedure Procedure Prompt Send DoEditText End_Procedure Procedure DoColumnFilter String sValgtFil sValgtFelt sTest Integer iAktFelt iMaxFelt iFundet iItem iBaseItem Integer iFile If (not(pFilOk(Self))) Procedure_Return Get piFileNumber to iFile Send popup of oColumnFilter_dg Get piChoosedField to iAktFelt If (iAktFelt = -1) Procedure_Return Send DoCreateGrid True 0 End_Procedure // Shift the current column one column to the right Procedure DoShiftColumnToRight Integer iColumns iActCol iShift iVal If (not(pFilOk(Self))) Procedure_Return Get item_count of aColumnFilters to iColumns If (iColumns = 0) Begin Send DoBuildAllColumnFilter Get item_count of aColumnFilters to iColumns End Get current_col to iActCol If ((iActCol + 1) = iColumns) Procedure_Return Get integer_value of aColumnFilters Item (iActCol + 1) to iShift Get integer_value of aColumnFilters Item iActCol to iVal Set array_value of aColumnFilters Item (iActCol + 1) to iVal Set array_Value of aColumnFilters Item iActCol to iShift Send DoCreateGrid True (iActCol + 1) End_Procedure // Shift the current column one column to the left Procedure DoShiftColumnToLeft Integer iColumns iActCol iShift iVal If (not(pFilOk(Self))) Procedure_Return Get item_count of aColumnFilters to iColumns If (iColumns = 0) Begin Send DoBuildAllColumnFilter Get item_count of aColumnFilters to iColumns End Get current_col to iActCol If ((iActCol - 1) = -1) Procedure_Return Get integer_value of aColumnFilters Item (iActCol - 1) to iShift Get integer_value of aColumnFilters Item iActCol to iVal Set array_value of aColumnFilters Item (iActCol - 1) to iVal Set array_Value of aColumnFilters Item iActCol to iShift Send DoCreateGrid True (iActCol - 1) End_Procedure // private // Build a column filter with all columns Procedure DoBuildAllColumnFilter Integer iMax iCnt iStartField iItem If (not(pFilOk(Self))) Procedure_Return Send Delete_data of aColumnFilters Get pDataNumFields to iMax Get FirstFieldnumber to iStartField Move 0 to iItem For iCnt From iStartField to iMax Set array_value of aColumnFilters Item iItem to iCnt Increment iItem Loop End_Procedure //AB-StoreEnd End_Object // oData //AB-StoreStart //AB-StoreEnd End_Object // oBox //AB-StoreStart On_Key Key_Ctrl+Key_E Send DoShell_Extentions On_Key Key_Alt+Key_W Send DoSelectWorkspace On_Key Key_Alt+Key_L Send DoSelectFileList On_Key Key_Ctrl+Key_N Send DoNewInstance On_Key KCancel Send None Procedure DoShell_Extentions Send Popup to oShell_Extentions End_Procedure Procedure DoKopier_Fra_Database If (not(pFilOk(Self))) Procedure_Return Send Popup to Kopier_Fra_Database Send DoCloseAllFiles Send DoUndersoegFil End_Procedure Procedure DoCopyFromFile If (not(pFilOk(Self))) Procedure_Return Send Popup to Copy_from_file Send DoCloseAllFiles Send DoUndersoegFil End_Procedure Procedure DoGlobalUtility Boolean bFilelistOk If (not(pFilOk(Self))) Procedure_Return Get pbFilelistUsed to bFilelistOk If (bFilelistOk) Begin Send DoCloseAllFiles Send Popup_modal of oReplace_view Send DoCloseAllFiles Send DoUndersoegFil End End_Procedure Procedure DoActivateQuery Boolean bFilelistOk If (not(pFilOk(Self))) Procedure_Return Get pbFilelistUsed to bFilelistOk If (bFilelistOk) Begin Send Request_CreateNewQuery End End_Procedure Procedure DoUndersoegFil Integer iFilOk iSystemfile antalfelter aktpos // iMax Integer lpLongFN lpShortFN iChars iFilFejl Number Felttype Feltlng Feltkomma antalrecords Integer Filenum iDrvFound iSeqFilenumber String sAktfil strTemp rootname sLine sDriver sTmpFilelist String sLongFN sShortFN sOpenAsFile sDriverName Integer iFile iRelFile iRelField iStartField Boolean bIsRecnumTable bOpened Get piFileNumber to iFile Send DoClearView If (iFile = 0) Begin // File is opening through File select or via shell. // Check to see if the file can be opened through the current filelist. Get OpenThroughFilelist to iFile If (iFile = 0) Begin Send Ignore_error of error_info_object DFERR_CANT_OPEN_FILE_LIST Set_Attribute DF_FILELIST_NAME to "" Send Trap_error of error_info_object DFERR_CANT_OPEN_FILE_LIST Set pbFilelistUsed to False Set enabled_state of oFilelist_bn to False Send DoShowOpenPathHelp Get NextFreeFilenumber to iFile Set piFilenumber to iFile End End Get psFilename to sAktfil Set value of (filStdreg(cntFil(Self))) to sAktfil Get DriverForOpenAs sAktFil to sOpenAsFile If (not(iFilFejl)) Begin Send ignore_all of Error_info_object Open sOpenAsFile as iFile Mode DF_SHARE Send trap_all of error_info_object Move (Found) to bOpened If (bOpened) Begin Move iFile to Filenum Set pFilOk to True Set psFilename to sAktFil Get_Attribute DF_FILE_IS_SYSTEM_FILE of Filenum to iSystemFile Set pSystemFile to iSystemFile Get_Attribute DF_FILE_NUMBER_FIELDS of FileNum to AntalFelter Set pDataNumFields to Antalfelter Get_Attribute DF_FILE_RECNUM_TABLE of FileNum to bIsRecnumTable Set pbRecnumFile to bIsRecnumTable If (bIsRecnumTable = True) Move 0 to iStartField Else Move 1 to iStartField Get_Attribute DF_FILE_DRIVER of FileNum to sDriverName If (sDriverName = "DATAFLEX") Begin Get_Attribute DF_FILE_MAX_RECORDS of FileNum to AntalRecords Set value of (oMaxRecords(cntStatus(Self))) Item 0 to AntalRecords Set enabled_state of (oMaxRecords(cntStatus(Self))) to True End Else Set value of (oMaxRecordS(cntStatus(Self))) Item 0 to "(na)" Send DumpRecordsUsed For Aktpos From iStartField to AntalFelter Get_Attribute DF_FIELD_NAME of FileNum Aktpos to strTemp Set array_value of aFildef Item (Aktpos * 4) to strTemp Get_Attribute DF_FIELD_TYPE of FileNum Aktpos to Felttype Set array_value of aFildef Item ((Aktpos * 4) + 1) to Felttype Get_Attribute DF_FIELD_LENGTH of FileNum Aktpos to feltlng Set array_value of aFildef Item ((Aktpos * 4) + 2) to Feltlng If (felttype = DF_BCD) Begin Get_Attribute DF_FIELD_PRECISION of Filenum Aktpos to feltkomma Set array_value of aFildef Item ((Aktpos * 4) + 3) to Feltkomma End Loop Send DoCreateGrid False 0 End Else Begin Send info_box ('Cannot open this databasefile: "'+sAktFil+'"') End End Send Combo_Fill_List to (cmbIndex(cntFil(Self))) End_Procedure Procedure DoPaintTheList Handle hDDObj Get piGridDDObj to hDDObj If (hDDObj = 0) Procedure_Return Send Rebuild_constraints of hDDObj Send beginning_of_data of oData End_Procedure // Check out if a filelist.cfg is placed in the same directory as the choosen file. // If so, try to find the file in the filelist and return the filenumber. // If there is no path for the choosen file, try to open the file through the current filelist (if there is one). // NB: It is now possible to open a file by typing in the filenumber in the filename form. This is handled in this // function to retrieve the rootname for the filenumber instead. // If not sucessfull return 0. Function OpenThroughFilelist Returns Integer Integer iFile String sFilePath sPath sFilename sFilelist Boolean bFound bFilelistUsed bOnlyNumbers Move 0 to iFile Get psFilename to sFilePath Get IsInt sFilePath to bOnlyNumbers If (bOnlyNumbers) Begin Move sFilePath to iFile Get_Attribute DF_FILE_ROOT_NAME of iFile to sFilename If (sFilename <> "") Set psFilename to sFilename End If (iFile = 0) Begin Get ExtractFilePath sFilePath to sPath If (sPath <> "") Begin Move (sPath + "Filelist.cfg") to sFilelist Get vFilePathExists sFilelist to bFound If (bFound) Begin Get ExtractFileName sFilePath to sFilename Set_Attribute DF_FILELIST_NAME to sFilelist // Use the found filelist to search for the file. Set_Attribute DF_OPEN_PATH to sPath // Setup open search path to same path as the current file. Set pbFilelistUsed to True Set enabled_state of oFilelist_bn to True Send DoShowOpenPathHelp Get SearchFilelist sFilename to iFile End End End If (iFile = 0) Begin Get pbFilelistUsed to bFilelistUsed If (bFilelistUsed) Begin Get psFilename to sFilename Get SearchFilelist sFilename to iFile End End Set piFilenumber to iFile Function_Return iFile End_Function Function SearchFilelist String sFilename Returns Integer Integer iFile iSearchFile iVoid String sRootname Boolean bFound Move 0 to iFile Move 0 to iSearchFile Move False to bFound Move (Uppercase(sFilename)) to sFilename Move (Trim(sFilename)) to sFilename Move (Replace(".INT", sFilename, "")) to sFilename Move (Replace(".DAT", sFilename, "")) to sFilename Repeat Get_Attribute DF_FILE_NEXT_USED of iSearchFile to iSearchFile If (iSearchFile <> 0) Begin Get_Attribute DF_FILE_ROOT_NAME of iSearchFile to sRootname Get StripPrefix sRootname to sRootname If (sRootname = sFilename) Move True to bFound If (bFound) Move iSearchFile to iFile End Until (iSearchFile = 0 or iFile > 0) Function_Return iFile End_Function Procedure DoZeroFile String sValgtFil Integer iNyMaxRec StructHandle iRetVal iFile iFile2 iRecords Get piFileNumber to iFile2 Get NextFreeFilenumber iFile2 to iFile If (iFile = 0) Procedure_Return // This destruction of data may be good to ask the user for. Get_Attribute DF_FILE_RECORDS_USED of iFile2 to iRecords Get yesno_box ("This will delete ALL "+String(iRecords)+" records!\n\n Are you sure?") "BIG DATALOSS WARNING!" MB_DEFBUTTON2 to iRetVal If (iRetVal <> MBR_YES) Procedure_Return Send DoShowWorking "Deleting all records." Send DoCloseAllFiles Get psFilename to sValgtFil If (sValgtFil = "") Procedure_Return Open sValgtFil as iFile Mode DF_EXCLUSIVE If (Found) Begin Zerofile iFile End Close iFile Send DoUndersoegFil Send DoLukInfopanel End_Procedure Procedure DoReindexAll String sValgtFil Integer iNyMaxRec StructHandle iFile iFile2 Handle hDDObj Get piFileNumber to iFile2 Get NextFreeFilenumber iFile2 to iFile If (iFile = 0) Procedure_Return Get psFilename to sValgtFil If (sValgtFil = "") Procedure_Return Send DoCloseAllFiles Open sValgtFil as iFile Mode DF_EXCLUSIVE If (Found) Begin Send activate to resinfo Sort iFile "" ((DF_SORT_OPTION_BAD_DATA_FIXUP) ior (DF_SORT_OPTION_DUP_DATA_ABORT)) (Resinfo(Self)) Send Close_panel to resinfo End Close iFile Send DoUndersoegFil End_Procedure Procedure DoGotoField Send DoGotoField of oData C_WITH_POPUP End_Procedure // Activate the field that was found in the findtext dialog Procedure DoGotoFieldFound Integer hoDialog String sFieldName Move (oFindText_dg(Self)) to hoDialog If (hoDialog <> 0) Begin Get psFieldNameFound of hoDialog to sFieldName Set pValgtFelt to sFieldName Send DoGotoField of oData C_WITHOUT_POPUP End End_Procedure // DoGotoFieldFound Procedure DoTextSearch String sSearchText Integer hoAnyflex_DD Integer hoFocus Get Focus of Desktop to hoFocus If (hoFocus <> (oData(oBox(Self)))) Begin // If the focus is not on the data when activating the search // then the gotofield logic fails. This is our quick workaround. Send Activate to (oData(oBox(Self))) End Get piGridDDObj to hoAnyflex_DD If (hoAnyflex_DD <> 0) Begin Set phoAnyFlex_DD of oFindText_dg to hoAnyflex_DD Send Popup of oFindText_dg End Else Error 300 "No datadictionary exist to search from." End_Procedure // DoTextSearch Procedure DoFindNextText String sText Get psSearchText of oFindText_dg to sText If (sText <> "") Send FindNext of oFindText_dg Else Send DoTextSearch End_Procedure // DoFindNextText Procedure DoSelectWorkspace Send KeyAction of (oWorkspace_bn(CntFil(Self))) End_Procedure // DoSelectWorkspace Procedure DoSelectFileList Send KeyAction of (oFilelist_bn(CntFil(Self))) End_Procedure // DoSelectFileList Procedure DoCreateGrid Boolean bDoReorder Integer iShowColumn Send DoCreateGrid of oData bDoReorder iShowColumn End_Procedure Procedure DumpRecordsUsed Integer AntalRecords iFile Get piFileNumber to iFile If (iFile = 0) Procedure_Return Get_Attribute DF_FILE_RECORDS_USED of iFile to AntalRecords Set value of (filRecords(cntStatus(Self))) Item 0 to AntalRecords End_Procedure Procedure DoFilterSetup If (not(pFilOk(Self))) Procedure_Return Set plsFilter of oFilterSetup to (plsFilter(piGridDDObj(Self))) Send Popup to oFilterSetup Set plsFilter of (piGridDDObj(Self)) to (plsFilter(oFilterSetup(Self))) If (SizeOfArray(plsFilter(piGridDDObj(Self))) > 0) Set pbFilterActive of (piGridDDObj(Self)) to True Send DoPaintTheList End_Procedure Procedure DoToggleFullView Boolean bMode Integer cxy If (not(pFilOk(Self))) Procedure_Return Get pbFullViewMode to bMode Move (not(bMode)) to bMode Set pbFullViewMode to bMode If (bMode = True) Begin Set enabled_State of cntFil to False Set enabled_state of cntStatus to False Set visible_state of cntFil to False Set visible_state of cntStatus to False Set caption_bar of main to False Set StatusBar_state to False Set location of oBox to 0 0 Get GuiSize to cxy Set GuiSize to (Hi(cxy)) (Low(cxy)) End Else Begin Set enabled_State of cntFil to True Set enabled_state of cntStatus to True Set visible_state of cntFil to True Set visible_state of cntStatus to True Set caption_bar of main to True Set StatusBar_state to True Set Location of oBox to 33 0 Get GuiSize to cxy Set GuiSize to (Hi(cxy)) (Low(cxy)) End End_Procedure Procedure DoAutoRefresh Integer iValue If (not(pFilOk(Self))) Procedure_Return Send Popup of RefreshTimer Get piChangedTo of RefreshTimer to iValue If (iValue = -1) Procedure_Return If (iValue = 0) Begin Set Timer_Active_state of oRefreshTimer to False End Else Begin Move (iValue * 1000) to iValue Set TimeOut of oRefreshTimer to iValue Set Timer_Active_state of oRefreshTimer to True End End_Procedure Procedure DoPageRefresh Send OnRefreshTimer of oData End_Procedure Procedure DoClearView Handle hDDObj Integer iOldState String sTmpFilelist Boolean bOk Send ignore_error of Error_info_object DFERR_FILE_NOT_OPEN Set value of filRecords to "No file opened." Set enabled_state of (oMaxRecords(cntStatus(Self))) to False Set value of oMaxRecords to "No file opened." Set value of filStdreg to "" Set pIndexChangeOk to False Send Combo_delete_data of cmbIndex Set pIndexChangeOk to True Send delete_data of aFilDef Send Delete_data of aColumnFilters Set pFilOk to False Set pSystemFile to False Set pbRecnumFile to False Get dynamic_update_state of oData to iOldState Set dynamic_update_state of oData to False Send DoMakeColumnVisible of oData 0 Get piGridDDObj to hDDObj If (hDDObj > 0) Begin Send Disconnect_Deos_From_Servers of oData Detach_Always Send Destroy of hDDObj End Send DoCloseAllFiles Set piGridDDObj to 0 Set main_file of oData to 0 If (Element(oData(oBox(Self))) <> 0) Send destroy to (Element(oData(oBox(Self)))) Send Delete_data of oData Set Item_Limit of oData to 1 Set Line_Width of oData to 0 (displayable_rows(oData(oBox(Self)))) Set Matrix_Size of oData to 0 (displayable_rows(oData(oBox(Self)))) Set form_Guiwidth of oData Item 0 to 65535 Set Header_Label of oData Item 0 to "" Set dynamic_update_state of oData to iOldState Set enabled_state of oData to False Set pInternalFilenumber to 0 // Keep current filelist (and if selected the current workspace). Send Trap_error of Error_info_object DFERR_FILE_NOT_OPEN End_Procedure Procedure OnRefreshTimer Send OnRefreshTimer of oData End_Procedure Procedure DoCountFilterRecords Integer iRecords Get CountFilterRecords to iRecords Send info_box ("Filter records:"*String(iRecords)) End_Procedure Function CountFilterRecords Returns Integer Integer iFile iCount Handle hDDObj RowID rwRecord Boolean bFound Get piFilenumber to iFile If (iFile = 0) Function_Return 0 Send DoShowWorking "Counting records..." Send cursor_wait of cursor_control Get piGridDDObj to hDDObj Get CurrentRowId of hDDObj to rwRecord Move 0 to Constrain_found_count Move 0 to Constrain_tests_count Constrained_Find First iFile by -1 While (Found) If (Mod(Constrain_found_count, 100) = 0) Begin Set value of (tekst2(info_panel(Self))) to (String(Constrain_found_count)*"of"*String(Constrain_tests_count)) End Constrained_Find Next Loop Move Constrain_found_count to iCount Set value of (tekst2(info_panel(Self))) to (String(Constrain_found_count)*"of"*String(Constrain_tests_count)) Clear iFile Move (FindByRowId(iFile, rwRecord)) to bFound Send DoLukInfoPanel Send cursor_ready of cursor_control Function_Return iCount End_Function Object oRecordContents is An array End_Object // Save the contents of the current record. Procedure BackupFields Integer iFile Integer iNoOfFields iField iType iStartField String sData Send delete_data of oRecordcontents Get_Attribute DF_FILE_NUMBER_FIELDS of iFile to iNoOfFields Get FirstFieldnumber to iStartField For iField From iStartField to iNoOfFields Get_Attribute DF_FIELD_TYPE of iFile iField to iType If (iType <> DF_OVERLAP) Begin Get_Field_Value iFile iField to sData Set array_value of oRecordContents Item iField to sData End Else Set array_value of oRecordContents Item iField to "Dummy" Loop End_Procedure // Restores content of the previously backuped record. Procedure RestoreFields Integer iFile Integer iNoOfFields iField iType iStartField String sData Get_Attribute DF_FILE_NUMBER_FIELDS of iFile to iNoOfFields Get FirstFieldnumber to iStartField For iField From iStartField to iNoOfFields Get_Attribute DF_FIELD_TYPE of iFile iField to iType If (iType <> DF_OVERLAP) Begin Get string_value of oRecordContents Item iField to sData Set_Field_Value iFile iField to sData End Loop End_Procedure // Fills the current column with a specified value. // Take filters into account Procedure DoFillCurrentColumn String sFillValue sFieldname Handle hDDObj Boolean bChanged bFound Integer iItem iField iCount iChanged iFile RowID rwRecord If (not(pFilOk(Self))) Procedure_Return Get piFilenumber to iFile If (iFile = 0) Procedure_Return Get piGridDDObj to hDDObj Get should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Get current_item of oData to iItem Get Data_field of oData Item iItem to iField Get String_value of aFilDef Item (iField * 4) to sFieldname Set label of FillValue_dg to ("Fill value for column "+sFieldname) Send popup of FillValue_dg Set label of FillValue_dg to "Fill value for current column" Get psFillValue to sFillValue If (sFillValue <> "*FILLANYFLEX*") Begin Send DoShowWorking "Modifing records." Send cursor_wait of cursor_control Get CurrentRowId of hDDObj to rwRecord Move 0 to Constrain_found_count Move 0 to Constrain_tests_count Move 0 to iChanged Constrained_Find First iFile by -1 While (Found) Send BackupFields iFile Indicate err False Reread iFile Set_Field_Value iFile iField to sFillValue Saverecord iFile Unlock If (not(err)) Increment iChanged If (Mod(iChanged, 100) = 0) Begin Move Constrain_found_count to iCount Set value of (tekst2(info_panel(Self))) to (String(iChanged)*"of"*String(iCount)) End Send RestoreFields iFile Constrained_Find Next Loop Move Constrain_found_count to iCount Clear iFile Move (FindByRowId(iFile, rwRecord)) to bFound Send DoLukInfoPanel Send cursor_ready of cursor_control Send DoPageRefresh Send info_box ("Records modified:"*String(iChanged)*"of"*String(iCount)) End End_Procedure // Converts the current column values from ANSI format to OEM format. // Take filters into account Procedure DoConvertColumnAnsiToOem Send DoConvertColumn CONV_TO_OEM End_Procedure Procedure DoConvertColumnOemToAnsi Send DoConvertColumn CONV_TO_ANSI End_Procedure // Converts the current column values from ANSI format to OEM format or the other way around. // Take filters into account Procedure DoConvertColumn Integer iMode String sFillValue Handle hDDObj Boolean bChanged bFound Integer iGemRecnum iItem iField iCount iChanged iFile RowID rwRecord If (not(pFilOk(Self))) Procedure_Return Get piFilenumber to iFile If (iFile = 0) Procedure_Return Get piGridDDObj to hDDObj Get should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Get current_item of oData to iItem Get Data_field of oData Item iItem to iField If (sFillValue <> "*FILLANYFLEX*") Begin Send DoShowWorking "Modifing records." Send cursor_wait of cursor_control Get CurrentRowId of hDDObj to rwRecord Move 0 to Constrain_found_count Move 0 to Constrain_tests_count Move 0 to iChanged Constrained_Find First iFile by -1 While (Found) Indicate err False Reread iFile Get_Field_Value iFile iField to sFillValue If (iMode = CONV_TO_ANSI) Move (ToAnsi(sFillValue)) to sFillValue Else Move (ToOEM(sFillValue)) to sFillValue Set_Field_Value iFile iField to sFillValue Saverecord iFile Unlock If (not(err)) Increment iChanged If (Mod(iChanged, 100) = 0) Begin Move Constrain_found_count to iCount Set value of (tekst2(info_panel(Self))) to (String(iChanged)*"of"*String(iCount)) End Constrained_Find Next Loop Move Constrain_found_count to iCount Clear iFile Move (FindByRowId(iFile, rwRecord)) to bFound Send DoLukInfoPanel Send cursor_ready of cursor_control Send DoPageRefresh Send info_box ("Records modified:"*String(iChanged)*"of"*String(iCount)) End End_Procedure Procedure DoOpenParentDD Integer iFilenumber End_Procedure // Delete all rows taking the current filters into account. Procedure DoDeleteAllRows String sFieldname Handle hDDObj Boolean bChanged Integer iGemRecnum iItem iField iCount iDeleted iFile Integer iSvar iRecords If (not(pFilOk(Self))) Procedure_Return Get piFilenumber to iFile If (iFile = 0) Procedure_Return Get piGridDDObj to hDDObj Get should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Get CountFilterRecords to iRecords Get yesno_box ("This will delete "+String(iRecords)+" records from the current filters!\n\nAre you sure?") "WARNING!" MB_DEFBUTTON2 to iSvar If (iSvar <> MBR_YES) Procedure_Return Send DoShowWorking "Deleting records." Send cursor_wait of cursor_control Move 0 to Constrain_found_count Move 0 to Constrain_tests_count Move 0 to iDeleted Constrained_Find First iFile by -1 While (Found) Send BackupFields iFile Indicate err False Delete iFile If (not(err)) Increment iDeleted If (Mod(iDeleted, 100) = 0) Begin Move Constrain_found_count to iCount Set value of (tekst2(info_panel(Self))) to (String(iDeleted)*"of"*String(iCount)) End Send RestoreFields iFile Constrained_Find Next Loop Move Constrain_found_count to iCount Clear iFile Send DoLukInfoPanel Send cursor_ready of cursor_control Send DoPageRefresh Send info_box ("Records deleted:"*String(iDeleted)*"of"*String(iCount)) End_Procedure // Start up commands: // {path+file to open} // {path+file to open} NEW // {path+file to open} RECNUM {recnum to find} // {path+file to open} ROWID {serialized rowid to find} Procedure Activate String pa1 pa2 pa3 sDir Integer iEngage iFirsttimer iPos Integer er_aktiv iNumArgs iArg iField Handle hoCmdLine hFile Boolean bFound Get er_aktiveret to er_aktiv If (not(er_aktiv)) Begin Set er_aktiveret to True Set piFilenumber to 0 Get phoCommandLine of oApplication to hoCmdLine Get CountOfArgs of hoCmdLine to iNumArgs If (iNumArgs > 0) Move (ToOEM(Argument(hoCmdLine, 1))) to pa1 If (iNumArgs > 1) Move (ToOEM(Argument(hocmdLine, 2))) to pa2 If (iNumArgs > 2) Move (ToOEM(Argument(hocmdLine, 3))) to pa3 Move (Uppercase(Trim(pa2))) to pa2 // Showln "CountOfArgs " iNumArgs // Showln "pa1 " pa1 // Showln "pa2 " pa2 // Showln "pa3 " pa3 // Test // Move "D:\Udvk111\Testarea\Data\adrs.dat" to pa1 Set psFileName to pa1 Case Begin Case (pa2 = "RECNUM") Send DoUndersoegFil Send StartUpFindRecnum pa3 Case Break Case (pa2 = "ROWID") Send DoUndersoegFil Send StartUpFindRowId pa3 Case Break Case (pa2 = "NEW") Move 0 to hFile Structure_Start hFile "DATAFLEX" Set_Attribute DF_FILE_PHYSICAL_NAME of hFile to pa1 // If AnyFlex should provide with some default columns. // Move 0 To iField // new field // Create_Field hFile At iField // Set_Attribute DF_FIELD_TYPE Of hFile iField To DF_BCD // Set_Attribute DF_FIELD_LENGTH Of hFile iField To 30 // Set_Attribute DF_FIELD_NAME Of hFile iField To "Col1" // Move 0 To iField // new field // Create_Field hFile At iField // Set_Attribute DF_FIELD_TYPE Of hFile iField To DF_ASCII // Set_Attribute DF_FIELD_LENGTH Of hFile iField To 30 // Set_Attribute DF_FIELD_NAME Of hFile iField To "Col2" // Move 0 To iField // new field // Create_Field hFile At iField // Set_Attribute DF_FIELD_TYPE Of hFile iField To DF_ASCII // Set_Attribute DF_FIELD_LENGTH Of hFile iField To 30 // Set_Attribute DF_FIELD_NAME of hFile iField to "Col3" Structure_End hFile DF_STRUCTEND_OPT_FORCE Send DoUndersoegFil Case Break Case Else If (pa1 <> "") Send DoUndersoegFil Case End End If (not(pFilOk(Self))) Send DoPaintTheList Forward Send activate Set View_Mode to viewmode_zoom End_Procedure // Find a record with recnum. // Used during application startup. Procedure StartUpFindRecnum String sRecnum Boolean bOk bChanged Integer iFile Handle hDDObj If (not(pFilOk(Self))) Procedure_Return Get piFilenumber to iFile If (iFile = 0) Procedure_Return Get piGridDDObj to hDDObj Get should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Get IsInt sRecnum to bOk If (not(bOk)) Procedure_Return Send Clear of hDDObj Send find_by_recnum of hDDObj iFile sRecnum End_Procedure // Find a record with rowid. // Used during application startup. Procedure StartUpFindRowId String sSerializedRowId Boolean bOk bChanged Integer iFile Handle hDDObj RowID rwRowId If (not(pFilOk(Self))) Procedure_Return Get piFilenumber to iFile If (iFile = 0) Procedure_Return Get piGridDDObj to hDDObj Get should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Move (DeSerializeRowId(sSerializedRowId)) to rwRowId Send Clear of hDDObj Send FindByRowId of hDDObj iFile rwRowId End_Procedure Procedure Page_delete // Send DoClearView // 1/10 2005 - Removed again, since it caused the runtime to make an critical error // when closing the application and column filters has been used. Set pFilOk to False Forward Send Page_delete End_Procedure #IFDEF WithColumnProperties Procedure DoColumnProperties Integer iFile iItem iField iLength iPrecision iType Integer iNewLength iNewPrecision iNewType iSelectedFunction Handle hDDObj StructHandle Boolean bChanged String sFieldname sType sNewType sValgtFil sNewFieldname If (not(pFilOk(Self))) Procedure_Return Get piFilenumber to iFile If (iFile = 0) Procedure_Return Get piGridDDObj to hDDObj Get should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Get current_item of oData to iItem Get Data_field of oData Item iItem to iField Get String_value of aFilDef Item (iField * 4) to sFieldname Set label of oColumnProps to ("Column properties for "+sFieldname) Set value of (oName(oColumnProps(Self))) to sFieldname Get Integer_value of aFilDef Item ((iField * 4) + 1) to iType Get beskrivFelttype iType to sType Set value of (oType(oColumnProps(Self))) to sType Get Integer_value of aFilDef Item ((iField * 4) + 2) to iLength Set value of (oLength(oColumnProps(Self))) to iLength Get Integer_value of aFilDef Item ((iField * 4) + 3) to iPrecision Set value of (oPrecision(oColumnProps(Self))) to iPrecision Send Popup of oColumnProps Get piSelectedFunction of oColumnProps to iSelectedFunction If (iSelectedFunction = COLUMNPROPS_CANCEL) Procedure_Return Get value of (oName(oColumnProps(Self))) to sNewFieldname Get value of (oType(oColumnProps(Self))) to sNewType Get ErFeltType sNewType to iNewType Get value of (oLength(oColumnProps(Self))) to iNewLength Get value of (oPrecision(oColumnProps(Self))) to iNewPrecision Case Begin Case (iSelectedFunction = COLUMNPROPS_OK or iSelectedFunction = COLUMNPROPS_NEW) Send DoCloseAllFiles Get psFilename to sValgtFil Open sValgtFil as iFile Mode DF_EXCLUSIVE If (Found) Begin Send activate to resinfo Move iFile to StructHandle Structure_Start StructHandle If (iSelectedFunction = COLUMNPROPS_NEW) Begin Move 0 to iField // Always at the field at the end. Create_Field StructHandle At iField End Set_Attribute DF_FIELD_TYPE of StructHandle iField to iNewType If (iNewType <> DF_DATE) Set_Attribute DF_FIELD_LENGTH of StructHandle iField to iNewLength If (iNewType = DF_BCD) Set_Attribute DF_FIELD_PRECISION of StructHandle iField to iNewPrecision Set_Attribute DF_FIELD_NAME of StructHandle iField to sNewFieldName Structure_End StructHandle DF_STRUCTEND_OPT_NONE "" (resinfo(Self)) Send Close_panel to resinfo End Close iFile Send DoUndersoegFil Case Break Case (iSelectedFunction = COLUMNPROPS_DELETE) Send DoCloseAllFiles Get psFilename to sValgtFil Open sValgtFil as iFile Mode DF_EXCLUSIVE If (Found) Begin Send activate to resinfo Move iFile to StructHandle Structure_Start StructHandle Delete_Field StructHandle iField Structure_End StructHandle DF_STRUCTEND_OPT_NONE "" (resinfo(Self)) Send Close_panel to resinfo End Close iFile Send DoUndersoegFil Case Break Case End End_Procedure #ENDIF // Starts a new Anyflex application with the current file opened and current record selected. Procedure DoNewInstance String sValgtFil sAnyFlexExe sAnyFlexPath sParam sSerializedRowId Handle hDDObj RowID rwRecord If (not(pFilOk(Self))) Procedure_Return Get psFilename to sValgtFil If (sValgtFil = "") Procedure_Return Get piGridDDObj to hDDObj Get CurrentRowId of hDDObj to rwRecord Move (SerializeRowId(rwRecord)) to sSerializedRowId Move (SysConf(sysconf_runtime_name)) to sAnyFlexExe Get ExtractFilePath sAnyFlexExe to sAnyFlexPath Move (C34 + sAnyFlexExe + C34) to sAnyFlexExe Move (C34 + sValgtFil + C34 + " ROWID " + sSerializedRowId) to sParam Move (C34 + sAnyFlexPath + C34) to sAnyFlexPath Send vShellExecute "OPEN" sAnyFlexExe sParam sAnyFlexPath End_Procedure // Modifies the current filelist. Procedure DoModifyFilelist Boolean bFilelistOk If (not(pFilOk(Self))) Procedure_Return Get pbFilelistUsed to bFilelistOk If (bFilelistOk) Begin Send DoCloseAllFiles Send Popup_modal of oModifyFilelist Send DoCloseAllFiles Send DoUndersoegFil End End_Procedure //AB-StoreEnd End_Object // tilpas_vw //AB-StoreStart //AB-StoreEnd //AB/ End_Object // prj