Register_Object oEditorView Use Dfentry.pkg Use AnyFlex.dd Use Retxt.dg Use Editer_record.dg Use Shell_Extentions.dg Use Brug_Filelist.sl Use Kopier_Fra_Database.dg Use Filtersetup.dg Use RefreshTimer.dg Use EditIndexes.dg Use Copy_from_file.dg Use FindText.dg Use FillValue.dg Use Columnprops.dg Use ModifyFilelist.dg Use RecordCount.dg Use cDbCJGrid.pkg Use cDbCJGridColumn.pkg Use cCJGridColumnRowIndicator.pkg Use cCJCommandBarSystem.pkg Use cIndexComboForm.pkg Use Structs\tsFilter.pkg Use Constants\Conv.pkg Activate_View Activate_oEditorView for oEditorView Object oEditorView is a dbView Property Boolean pbFullViewMode False Property Boolean pbUndersoegFil False // True if there is a file opened. // TODO: Change to check for Server DD handle <> 0. Property Boolean pbFileOpened False Property Integer piFindRecnum 0 Property RowID prwFindRowID (NullRowID()) Property Boolean pbSetZomm True Set Border_Style to Border_Thick Set Caption_Bar to False Set Minimize_Icon to False Set Label to "Edit databasefile" Set Location to 0 0 Set Size to 266 450 Set Auto_Clear_DEO_State to False Set pbAutoActivate to True 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 Object cntFil is a Container3d Set Location to 1 1 Set Size to 32 448 Set peAnchors to anTopLeftRight Object filStdreg is a Form Set Label to "Filename:" Set Size to 13 361 Set Location to 1 37 Set peAnchors to anTopLeftRight Set Label_Col_Offset to 35 Set Prompt_Button_Mode to pb_PromptOn 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(pbFileOpened(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 of oFilesystem (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 Set pbUndersoegFil to True End_Procedure End_Object Object oComboIndex is a cIndexComboForm Set Size to 13 361 Set Location to 15 37 Set peAnchors to anTopLeftRight Procedure OnIndexChanged Integer iIndex Boolean bDoSave Handle hDDObj Send Request_Clear of oData Get Server to hDDObj Get Should_Save of hDDObj to bDoSave If (bDoSave) Procedure_Return Send Activate of oData Set Ordering of oData to iIndex Set Ordering of hDDObj to iIndex Send DoPaintTheList End_Procedure End_Object Object oFilelist_bn is a Button Set Label to "File&list" Set Size to 14 43 Set Location to 1 400 Set peAnchors to anRight 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 Set pbUndersoegFil to True End_Procedure End_Object Object oWorkspace_bn is a Button Set Label to "&Workspace" Set Size to 14 43 Set Location to 15 400 Set peAnchors to anRight 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 Set pbFilelistUsed to True End End End_Procedure End_Object End_Object 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" Set visible_state to False End_Object Object oBox is a dbContainer3d Set Size to 231 448 Set Location to 34 1 Set peAnchors to anAll Set pbAcceptDropFiles to True Object oData is a cDbCJGrid Set Size to 227 444 Set Location to 0 0 Set peAnchors to anAll Set Verify_Delete_msg to get_no_confirmation Set Enabled_State to False Set pbAutoColumnSizing to False Set pbDrawGridForEmptySpace to False Set piGridLineColor to 14342361 Set Color to clWhite Set piAlternateRowBackgroundColor to 15263976 Set pbUseAlternateRowBackgroundColor to True Set piFocusCellBackColor to 14667984 Object oDataMenu is a cCJContextMenu Object oExtensionsetupMenuItem is a cCJMenuItem Set psCaption to "Extension setup" Set psTooltip to "Extension setup" Set psShortcut to "Ctrl+E" Procedure OnExecute Variant vCommandBarControl Send DoShell_Extentions End_Procedure End_Object Object oChoosefieldfromsearchlistMenuItem is a cCJMenuItem Set psCaption to "Choose field from searchlist" Set psTooltip to "Choose field from searchlist" Set psShortcut to "Ctrl+S" Set pbControlBeginGroup to True Procedure OnExecute Variant vCommandBarControl Send DoGotoField End_Procedure End_Object Object oRecordcountMenuItem is a cCJMenuItem Set psCaption to "Record count" Set psTooltip to "Record count" Procedure OnExecute Variant vCommandBarControl Send DoRecordCount End_Procedure End_Object Object oFilterrecordsMenuItem is a cCJMenuItem Set psCaption to "Filter records" Set psTooltip to "Filter records" Set peControlType to xtpControlPopup Object oFiltersetupMenuItem is a cCJMenuItem Set psCaption to "Filter setup" Set psTooltip to "Filter setup" Set psShortcut to "Ctrl+F" Procedure OnExecute Variant vCommandBarControl Send DoFilterSetup End_Procedure End_Object Object oTogglefilteractiveMenuItem is a cCJMenuItem Set psCaption to "Filter active" Set psTooltip to "Filter active" Set psShortcut to "Alt+F" Set pbControlBeginGroup to True Procedure OnExecute Variant vCommandBarControl Send DoToogleFilterActive End_Procedure Function IsChecked Returns Boolean Boolean bFilterActive Handle hDDObj Get Server to hDDObj Get pbFilterActive of hDDObj to bFilterActive Function_Return bFilterActive End_Function End_Object Object oCountfilterrecordsMenuItem is a cCJMenuItem Set psCaption to "Count filter records" Set psTooltip to "Count filter records" Set psShortcut to "Ctrl+D" Procedure OnExecute Variant vCommandBarControl Send DoCountFilterRecords End_Procedure End_Object Object oClearallfiltersMenuItem is a cCJMenuItem Set psCaption to "Clear all filters" Set psTooltip to "Clear all filters" Set psShortcut to "Ctrl+Q" Procedure OnExecute Variant vCommandBarControl Send DoClearFilters End_Procedure End_Object Object oMakefilterforcurrentvalueMenuItem is a cCJMenuItem Set psCaption to "Make filter for current value" Set psTooltip to "Make filter for current value" Set psShortcut to "Enter" Procedure OnExecute Variant vCommandBarControl Send DoMakeFilter End_Procedure End_Object End_Object Object oDeleterecordsMenuItem is a cCJMenuItem Set psCaption to "Delete records" Set psTooltip to "Delete records" Set peControlType to xtpControlPopup Object oZerofileDeleteallrecordsMenuItem1 is a cCJMenuItem Set psCaption to "Zerofile - Delete all records" Set psTooltip to "Zerofile - Delete all records" Set psShortcut to "Ctrl+Delete" Procedure OnExecute Variant vCommandBarControl Send DoZeroFile End_Procedure End_Object Object oDeleteallrowsofcurrentfiltersMenuItem is a cCJMenuItem Set psCaption to "Delete all rows of current filters" Set psTooltip to "Delete all rows of current filters" Procedure OnExecute Variant vCommandBarControl Send DoDeleteAllRows End_Procedure End_Object End_Object Object oModifytableMenuItem is a cCJMenuItem Set psCaption to "Modify table" Set psTooltip to "Modify table" Set peControlType to xtpControlPopup Object oReindexallindexesMenuItem1 is a cCJMenuItem Set psCaption to "Reindex all indexes" Set psTooltip to "Reindex all indexes" Set psShortcut to "Ctrl+R" Procedure OnExecute Variant vCommandBarControl Send DoReindexAll End_Procedure End_Object Object oEditindexesMenuItem1 is a cCJMenuItem Set psCaption to "Edit indexes" Set psTooltip to "Edit indexes" Set psShortcut to "Ctrl+I" Procedure OnExecute Variant vCommandBarControl Send DoEditIndexes End_Procedure End_Object Object oEditcolumnsMenuItem is a cCJMenuItem Set psCaption to "Edit columns" Set psTooltip to "Edit columns" Set psShortcut to "Ctrl+M" Procedure OnExecute Variant vCommandBarControl Send DoColumnProperties End_Procedure End_Object End_Object Object oModifyfilelistMenuItem is a cCJMenuItem Set psCaption to "Modify filelist" Set psTooltip to "Modify filelist" Set psShortcut to "Ctrl+B" Procedure OnExecute Variant vCommandBarControl Send DoModifyFilelist End_Procedure End_Object Object oFillcurrentcolumnMenuItem is a cCJMenuItem Set psCaption to "Fill current column" Set psTooltip to "Fill current column" Set psShortcut to "Ctrl+U" Set pbControlBeginGroup to True Procedure OnExecute Variant vCommandBarControl Send DoFillCurrentColumn End_Procedure End_Object Object oCopyfromdatabasetodatabaseMenuItem is a cCJMenuItem Set psCaption to "Copy from database to database" Set psTooltip to "Copy from database to database" Set psShortcut to "Ctrl+K" Procedure OnExecute Variant vCommandBarControl Send DoKopier_Fra_Database End_Procedure End_Object Object oImportfromtextfileMenuItem is a cCJMenuItem Set psCaption to "Import from textfile" Set psTooltip to "Import from textfile" Set psShortcut to "Ctrl+T" Procedure OnExecute Variant vCommandBarControl Send DoCopyFromFile End_Procedure End_Object Object oConvertcolumnMenuItem is a cCJMenuItem Set psCaption to "Convert column" Set psTooltip to "Convert column" Set peControlType to xtpControlPopup Object oConvertcolumnfromANSItoOEMMenuItem is a cCJMenuItem Set psCaption to "Convert column from ANSI to OEM" Set psTooltip to "Convert column from ANSI to OEM" Procedure OnExecute Variant vCommandBarControl Send DoConvertColumnAnsiToOem End_Procedure End_Object Object oConvertcolumnfromOEMtoANSIMenuItem is a cCJMenuItem Set psCaption to "Convert column from OEM to ANSI" Set psTooltip to "Convert column from OEM to ANSI" Procedure OnExecute Variant vCommandBarControl Send DoConvertColumnOemToAnsi End_Procedure End_Object End_Object Object oVDFQueryMenuItem is a cCJMenuItem Set psCaption to "VDFQuery" Set psTooltip to "VDFQuery" Set psShortcut to "Ctrl+P" Set pbControlBeginGroup to True Procedure OnExecute Variant vCommandBarControl Send DoActivateQuery End_Procedure End_Object Object oNewinstancewithcurrentrecordMenuItem is a cCJMenuItem Set psCaption to "New instance with current record" Set psTooltip to "New instance with current record" Set psShortcut to "Ctrl+N" Procedure OnExecute Variant vCommandBarControl Send DoNewInstance End_Procedure End_Object Object oTogglefullviewMenuItem is a cCJMenuItem Set psCaption to "Full view" Set psTooltip to "Full view" Set psShortcut to "Ctrl+W" Set pbControlBeginGroup to True Procedure OnExecute Variant vCommandBarControl Send DoToggleFullView End_Procedure Function IsChecked Returns Boolean Boolean bFullView Get pbFullViewMode to bFullView Function_Return bFullView End_Function End_Object Object oFullloadMenuItem is a cCJMenuItem Set psCaption to "Full load" Set psTooltip to "Full load" Procedure OnExecute Variant vCommandBarControl Send DoToggleFullLoad End_Procedure Function IsChecked Returns Boolean Boolean bFullLoad Get pbStaticData of oData to bFullLoad Function_Return bFullLoad End_Function End_Object Object oAutorefreshtimerMenuItem is a cCJMenuItem Set psCaption to "Autorefresh timer" Set psTooltip to "Autorefresh timer" Set psShortcut to "Ctrl+A" Procedure OnExecute Variant vCommandBarControl Send DoAutoRefresh End_Procedure Function IsChecked Returns Boolean Boolean bAutoTimer Get Timer_Active_state of oRefreshTimer to bAutoTimer Function_Return bAutoTimer End_Function End_Object Object oRefreshscreenmanuallyMenuItem is a cCJMenuItem Set psCaption to "Refresh screen manually" Set psTooltip to "Refresh screen manually" Set psShortcut to "Shift+F5" Procedure OnExecute Variant vCommandBarControl Send DoPageRefresh End_Procedure End_Object Object oEdittextMenuItem is a cCJMenuItem Set psCaption to "Edit text" Set psTooltip to "Edit text" Set psShortcut to "F4" Set pbControlBeginGroup to True Procedure OnExecute Variant vCommandBarControl Send DoEditText End_Procedure End_Object Object oEditrecordinzoomviewMenuItem is a cCJMenuItem Set psCaption to "Edit record in zoom view" Set psTooltip to "Edit record in zoom view" Set psShortcut to "F12" Procedure OnExecute Variant vCommandBarControl Send DoShowRecordView End_Procedure End_Object Object oFreetextsearchMenuItem is a cCJMenuItem Set psCaption to "Free text search" Set psTooltip to "Free text search" Set pbControlBeginGroup to True Procedure OnExecute Variant vCommandBarControl Send DoTextSearch End_Procedure End_Object Object oFindnexttextMenuItem is a cCJMenuItem Set psCaption to "Find next text" Set psTooltip to "Find next text" Set psShortcut to "F3" Procedure OnExecute Variant vCommandBarControl Send DoFindNextText End_Procedure End_Object Object oHelpMenuItem is a cCJMenuItem Set psCaption to "Help" Set psTooltip to "Help" Set psShortcut to "F1" Set pbControlBeginGroup to True Procedure OnExecute Variant vCommandBarControl Send DoHelp End_Procedure End_Object Object oAboutMenuItem is a cCJMenuItem Set psCaption to "About" Set psTooltip to "About" Set psShortcut to "Ctrl+F1" Procedure OnExecute Variant vCommandBarControl Send Activate_About End_Procedure End_Object End_Object Set phoContextMenu to oDataMenu 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_I Send DoEditIndexes On_Key Key_Ctrl+Key_K Send DoKopier_Fra_Database On_Key Key_Ctrl+Key_L send DoRecordCount On_Key Key_Ctrl+Key_M Send DoColumnProperties 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 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 // Arguments the procedure in the class. This bypass the load if the server property are not set yet. Procedure DataLoadAdjustOnAddFocus Handle hoServer Get Server to hoServer If (hoServer <> 0) Begin Forward Send DataLoadAdjustOnAddFocus End End_Procedure Procedure DoCreateGrid Boolean bDoReorder Integer iShowColumn Integer iField iFieldType iFieldLength iMaxFields Integer iColumn iDecimals iNumbersLeft iNumbersRight Integer iFile iHeaderSize iFieldSize iWidth iOffs Integer iStartField iStartIndexnumber iIndexSegments iIndexSegment Integer[] iFieldCreateOrder Integer iFieldsCreated iCreatedFieldAt Boolean bSystemFile String sFieldName sDescription Handle hDDObj hOldDD Handle hoColumn Get piFileNumber to iFile Get Server to hOldDD If (hOldDD > 0) Begin Set Server to 0 Set Server of oEditorView to 0 Set Main_DD of oEditorView to 0 Send Destroy of hOldDD End Send DestroyColumnObjects Get FirstIndexNumber to iStartIndexnumber Set ordering to iStartIndexnumber Clear iFile Get Create U_AnyFlex_DataDictionary to hDDObj Set main_file of hDDObj to iFile // What Set Server to hDDObj would do if grid was not activated. Set explicit_server_state to True Set private.Server to hDDObj Set Main_DD of oEditorView to hDDObj Set Server of oEditorView to hDDObj Set Ordering of hDDObj to iStartIndexnumber Get pDataNumFields to iMaxFields Get FirstFieldnumber to iStartField Get Create (RefClass(cCJGridColumnRowIndicator)) to hoColumn Get_Attribute DF_INDEX_NUMBER_SEGMENTS of iFile iStartIndexnumber to iIndexSegments For iIndexSegment from 1 to iIndexSegments Get_Attribute DF_INDEX_SEGMENT_FIELD of iFile iStartIndexnumber iIndexSegment to iField Move (SearchArray(iField, iFieldCreateOrder)) to iCreatedFieldAt If (iCreatedFieldAt = -1) Begin Move iField to iFieldCreateOrder[iFieldsCreated] Increment iFieldsCreated End Loop For iField from iStartField to iMaxFields Move (SearchArray(iField, iFieldCreateOrder)) to iCreatedFieldAt If (iCreatedFieldAt = -1) Begin Move iField to iFieldCreateOrder[iFieldsCreated] Increment iFieldsCreated End Loop For iField from iStartField to iMaxFields Get Create (RefClass(cDbCJGridColumn)) to hoColumn Set piBindingTable of hoColumn to iFile Set piBindingColumn of hoColumn to (iFieldCreateOrder[iField]) Send CopyDDFieldOptions of hoColumn hDDObj Loop Move 1 to iColumn For iCreatedFieldAt from iStartField to iMaxFields Get ColumnObject iColumn to hoColumn Move (iFieldCreateOrder[iCreatedFieldAt]) to iField Get_Attribute DF_FIELD_NAME of iFile iField to sFieldName Get_Attribute DF_FIELD_LENGTH of iFile iField to iFieldLength Get_Attribute DF_FIELD_TYPE of iFile iField to iFieldType Move (SFormat("Field: %1 Type: %2, %3", iField, FieldTypeDescription(Self, iFieldType), iFieldLength)) to sDescription Case Begin Case (iFieldType = DF_DATE) Move 10 to iFieldLength Case Break Case (iFieldType = DF_BCD) Get_Attribute DF_FIELD_PRECISION of iFile iField to iDecimals Move (iFieldLength - iDecimals) to iNumbersLeft Move iDecimals to iNumbersRight Move (SFormat("%1 (%2,%3)", sDescription, iNumbersLeft, iNumbersRight)) to sDescription Case Break Case (iFieldType = DF_ASCII) Case Break Case (iFieldType = DF_TEXT) Case Break Case (iFieldType = DF_OVERLAP) Set pbVisible of hoColumn to False Set pbEditable of hoColumn to False Case Break Case End Set psCaption of hoColumn to sFieldName Set status_help of hoColumn to sDescription Set label of oTxt1 to ("M"+sFieldname) Get GuiSize of oTxt1 to iOffs Move (Low(iOffs)) to iHeaderSize If (iFieldType <> DF_TEXT) Begin Set label of oTxt1 to (Repeat("n", iFieldLength)) Get GuiSize of oTxt1 to iOffs Move (Low(iOffs)) to iFieldSize End Else Begin Move 0 to iFieldSize End Move (iHeaderSize max iFieldSize) to iWidth Move (iWidth min 300) to iWidth // Max initial size of columns Set piWidth of hoColumn to iWidth Increment iColumn Loop Send CreateColumns Send BindDataSource Send Attach_Deo_To_Server Send StoreOriginalLayout Send MovetoFirstRow Get pSystemFile to bSystemFile Set pbAllowAppendRow to (not(bSystemFile)) Set pbAllowDeleteRow to (not(bSystemFile)) Set pbAllowInsertRow to (not(bSystemFile)) If (bDoReorder = True) Send OnIndexChanged of oComboIndex Set Enabled_State to True End_Procedure Procedure DoGotoField String sField String sSelectedField sTest Integer iFoundCol iColumns iCol Integer iFile Handle[] hoCols Handle hCol Boolean bVisible bOk If (not(pbFileOpened(Self))) Procedure_Return Get piFileNumber to iFile If (Num_arguments > 0) Move sField to sSelectedField Else Move "" to sSelectedField If (sSelectedField = "") Begin Get SelectedColumnObject to hCol If hCol Begin Get psCaption of hCol to sSelectedField End Get SelectField of oChooseField (&sSelectedField) to bOk If (not(bOk)) Procedure_Return End Move (Uppercase(sSelectedField)) to sSelectedField If (sSelectedField <> "") Begin Move -1 to iFoundCol Move 0 to iCol Get ColumnObjectsInDisplayOrder to hoCols Move (SizeOfArray(hoCols)) to iColumns While (iFoundCol = -1 and iCol < iColumns) Get psCaption of hoCols[iCol] to sTest Get pbVisible of hoCols[iCol] to bVisible If bVisible Begin If (Uppercase(sTest) = sSelectedField) Begin Move iCol to iFoundCol End End Increment iCol Loop If (iFoundCol > -1) Begin Get MoveToColumnObject hoCols[iFoundCol] to bOk End End End_Procedure // Disable ESC key in grid. Function verify_Exit Returns Integer Function_Return 1 End_Function Procedure DoMakeFilter Integer iFilterItems iField iFile String sFieldname sValue sMode Handle hDDObj hCol Boolean bOk tsFilter[] lsFilter Get SelectedColumnObject to hCol Get piBindingColumn of hCol to iField Get piBindingTable of hCol to iFile Get_Attribute DF_FIELD_NAME of iFile iField to sFieldname Get SelectedRowValue of hCol to sValue Get SelectMode of oMode_dg sFieldname (&sValue) (&sMode) to bOk If bOk Begin Get Server to hDDObj Get plsFilter of hDDObj to lsFilter Move (SizeOfArray(lsFilter)) to iFilterItems 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 End_Procedure // Activate or deactivate the current filter. Procedure DoToogleFilterActive Handle hDDObj Boolean bValue If (not(pbFileOpened(Self))) Procedure_Return Get Server 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 String[] saRowdata Handle hDDObj If (not(pbFileOpened(Self))) Procedure_Return Get piFileNumber to iFile Get pDataNumFields to iAntalFelter Get Server to hDDObj If (HasRecord(hDDObj)) Begin Get CurrentRowId of hDDObj to rwCurrentRecord Send Refind_records of hDDObj Get FirstFieldnumber to iStartField For aktpos From iStartField to iAntalFelter Get_Field_Value iFile aktpos to strTemp Move (Rtrim(strTemp)) to saRowdata[aktpos] Loop Send DoEditRow of Editer_record_dg saRowdata rwCurrentRecord End End_Procedure Procedure DoEditText Integer iField iFieldLength iFieldType String sText Integer iLines iFile iOldArgSize Handle hDDObj hCol Boolean bFound bOk Get SelectedColumnObject to hCol Get piBindingColumn of hCol to iField Get piBindingTable of hCol to iFile Get Server to hDDObj Get_Attribute DF_FIELD_TYPE of iFile iField to iFieldType If (iFieldType = DF_TEXT) Begin Get_Attribute DF_FIELD_LENGTH of iFile iField to iFieldLength Get_Argument_Size to iOldArgSize If (iOldArgSize < iFieldLength) Begin Set_Argument_Size iFieldLength End Get Field_Current_Value of hDDObj iField to sText Get EditText of retxt_dg (&sText) iFieldLength to bOk If bOk Begin Set Field_Changed_Value of hDDObj iField to sText Send Request_Save of hDDObj End If (iOldArgSize < iFieldLength) Begin Set_Argument_Size iOldArgSize End If bOk Begin Send DoPageRefresh End End End_Procedure // Clear constraints Procedure DoClearFilters Handle hDDObj Integer iMaxItems tsFilter[] lsFilter lsTomFilter Get Server 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 End End Send DoPaintTheList End_Procedure Procedure OnRefreshTimer Boolean bChanged Handle hDDObj If (not(pbFileOpened(Self))) Procedure_Return Get Server to hDDObj Get should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Send RefreshDataFromSelectedRow End_Procedure Procedure DoEditIndexes Boolean bChanged Handle hDDObj Integer iStartIndex If (not(pbFileOpened(Self))) Procedure_Return Get Server 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 Set pbUndersoegFil to True End End_Procedure Procedure Prompt Send DoEditText End_Procedure // Do not allow to close the view. Procedure Request_Cancel End_Procedure End_Object Procedure OnFileDropped String sFilename Boolean bLast String sExtention Forward Send OnFileDropped sFilename bLast If bLast Begin Get FileExtention of oFilesystem (Lowercase(sFilename)) to sExtention If (sExtention = "dat" or sExtention = "int") Begin // ToDo: Copy from database file End Else Begin Send DoCopyFromFile sFilename End End End_Procedure End_Object 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(pbFileOpened(Self))) Procedure_Return Send Popup to Kopier_Fra_Database Set pbUndersoegFil to True End_Procedure Procedure DoCopyFromFile String sImportFile Handle hServer String sCurrentFilename sImpFile If (not(pbFileOpened(Self))) Procedure_Return If (num_arguments > 0) Begin Move sImportFile to sImpFile End Else Begin Move "" to sImpFile End Get Server to hServer Get psFileName to sCurrentFilename Send DoCopyFromFile of Copy_from_file hServer sCurrentFilename sImpFile Set pbUndersoegFil to True End_Procedure Procedure DoActivateQuery Boolean bFilelistOk If (not(pbFileOpened(Self))) Procedure_Return Get pbFilelistUsed to bFilelistOk If (bFilelistOk) Begin Send Request_CreateNewQuery End End_Procedure Procedure DoUndersoegFil Integer iFilOk iSystemfile antalfelter aktpos 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 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 Move (Found) to bOpened Send trap_all of error_info_object If (bOpened) Begin Move iFile to Filenum Set pbFileOpened 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 Set psCurrentDriver to sDriverName 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 UserError (SFormat('Cannot open this databasefile: "%1"', sAktfil)) End End Send Combo_Fill_List of oComboIndex End_Procedure Procedure DoPaintTheList Handle hDDObj Get Server to hDDObj If (hDDObj = 0) Procedure_Return Send Rebuild_constraints of hDDObj Send MovetoFirstRow 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 sSystemDfPath Boolean bFound bFilelistUsed bOnlyNumbers Move 0 to iFile Get psFilename to sFilePath If (sFilePath <> "") Begin 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 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. Get_Profile_String "Workspaces" "SystemDfPath" to sSystemDfPath Set_Attribute DF_OPEN_PATH to (".;" + sPath + ";" + sSystemDfPath) Set pbFilelistUsed to True Set enabled_state of oFilelist_bn to True 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 Set pbUndersoegFil to True 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 DoStartResInfo of oResInfo Sort iFile "" ((DF_SORT_OPTION_BAD_DATA_FIXUP) ior (DF_SORT_OPTION_DUP_DATA_ABORT)) (oResInfo(Self)) Send DoStopResInfo of oResInfo End Close iFile Set pbUndersoegFil to True 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 Send DoGotoField of oData sFieldName End End_Procedure 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 Server 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 DoFilterSetup Handle hDDObj tsFilter[] lsFilter Boolean bOk If (not(pbFileOpened(Self))) Procedure_Return Get Server to hDDObj Get plsFilter of hDDObj to lsFilter Get SelectFilters of oFilterSetup (&lsFilter) to bOk If bOk Begin Set plsFilter of hDDObj to lsFilter If (SizeOfArray(lsFilter) > 0) Set pbFilterActive of hDDObj to True End Send DoPaintTheList End_Procedure Procedure DoToggleFullView Boolean bMode Integer cxy If (not(pbFileOpened(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 visible_state of cntFil 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 visible_state of cntFil 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(pbFileOpened(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 Send Combo_delete_data of oComboIndex Set pbFileOpened to False Set pSystemFile to False Set pbRecnumFile to False Send DoCloseAllFiles Get Server to hDDObj If (hDDObj > 0) Begin Set Server of oData to 0 Set Server to 0 Set Main_DD to 0 Send Destroy of hDDObj End Send DestroyColumnObjects of oData 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 If (iRecords <> 0) Begin Send info_box ("Filter records:"*String(iRecords)) End End_Procedure Function CountFilterRecords Returns Integer Integer iFile iCount Handle hDDObj RowID rwRecord Boolean bFound bStop Get piFilenumber to iFile If (iFile = 0) Function_Return 0 Send Initialize_StatusPanel of ghoStatusPanel "AnyFlex" "Count of records" "Counting..." Send Start_StatusPanel of ghoStatusPanel Get Server to hDDObj Get CurrentRowId of hDDObj to rwRecord Move 0 to Constrain_found_count Move 0 to Constrain_tests_count Send Request_Read of hDDObj FIRST_RECORD iFile -1 While ((Found) and bStop = False) Get Check_StatusPanel of ghoStatusPanel to bStop If (bStop = False) Begin If (Mod(Constrain_found_count, 100) = 0) Begin Send Update_StatusPanel of ghoStatusPanel (String(Constrain_found_count)*"of"*String(Constrain_tests_count)) End Send Request_Read of hDDObj NEXT_RECORD iFile -1 End Loop If (bStop = False) Begin Move Constrain_found_count to iCount End Send Update_StatusPanel of ghoStatusPanel (String(Constrain_found_count)*"of"*String(Constrain_tests_count)) Clear iFile Move (FindByRowId(iFile, rwRecord)) to bFound Send Update_StatusPanel of ghoStatusPanel "" Send Stop_StatusPanel of ghoStatusPanel Function_Return iCount End_Function // Save the contents of the current record. Function BackupFields Integer iFile Returns String[] Integer iNoOfFields iField iType iStartField Integer iArgumentSize iFieldLength String[] sData Get_Argument_Size to iArgumentSize 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_Attribute DF_FIELD_LENGTH of iFile iField to iFieldLength If (iArgumentSize < iFieldLength) Begin Set_Argument_Size iFieldLength Move iFieldLength to iArgumentSize End Get_Field_Value iFile iField to sData[iField] End Loop Function_Return sData End_Function // Restores content of the previously backuped record. Procedure RestoreFields Integer iFile String[] sData Integer iNoOfFields iField iType iStartField 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 Set_Field_Value iFile iField to sData[iField] End Loop End_Procedure // Fills the current column with a specified value. // Take filters into account Procedure DoFillCurrentColumn String sFillValue sFieldname sTestValue Handle hDDObj hCol Boolean bChanged bFound bStop bOk Integer iItem iField iCount iChanged iFile iOldArgumentSize String[] sBackupFields Get Server to hDDObj If (not(hDDObj)) Procedure_Return Get Should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Get SelectedColumnObject of oData to hCol Get piBindingColumn of hCol to iField Get piBindingTable of hCol to iFile Get_Attribute DF_FIELD_NAME of iFile iField to sFieldname Get SelectedRowValue of hCol to sFillValue Get FillValue of FillValue_dg sFieldname (&sFillValue) to bOk If bOk Begin Get_Argument_Size to iOldArgumentSize Send Initialize_StatusPanel of ghoStatusPanel "AnyFlex" "Fill current column" (SFormat("Filling with value: %1", sFillValue)) Send Start_StatusPanel of ghoStatusPanel Move 0 to Constrain_Found_Count Move 0 to Constrain_tests_count Move 0 to iChanged Send Request_Read of hDDObj FIRST_RECORD iFile -1 While ((Found) and bStop = False) Get Check_StatusPanel of ghoStatusPanel to bStop If (bStop = False) Begin Get_Field_Value iFile iField to sTestValue If (Rtrim(sTestValue) <> sFillValue) Begin Get BackupFields iFile to sBackupFields Reread iFile Set_Field_Value iFile iField to sFillValue SaveRecord iFile If (not(err)) Increment iChanged Unlock Send RestoreFields iFile sBackupFields End If (Mod(Constrain_found_count, 100) = 0) Begin Send Update_StatusPanel of ghoStatusPanel (SFormat("Records modified: %1 of %2", iChanged, Constrain_Tests_Count)) End Send Request_Read of hDDObj NEXT_RECORD iFile -1 End Loop Set_Argument_Size iOldArgumentSize Move Constrain_Tests_Count to iCount Send Update_StatusPanel of ghoStatusPanel (SFormat("Records modified: %1 of %2", iChanged, iCount)) Send Refind_Records of hDDObj Send DoPageRefresh Send Update_StatusPanel of ghoStatusPanel "" Send Stop_StatusPanel of ghoStatusPanel Send info_box (SFormat("Records modified: %1 of %2", iChanged, 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 sTestValue sFieldName Handle hDDObj hCol Boolean bChanged bFound bStop Integer iField iCount iChanged iFile iOldArgumentSize iFieldLength String[] sBackupFields Get Server to hDDObj If (not(hDDObj)) Procedure_Return Get should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Get SelectedColumnObject of oData to hCol Get piBindingColumn of hCol to iField Get piBindingTable of hCol to iFile Get_Attribute DF_FIELD_NAME of iFile iField to sFieldname Get_Argument_Size to iOldArgumentSize Get_Attribute DF_FIELD_LENGTH of iFile iField to iFieldLength If (iOldArgumentSize < iFieldLength) Begin Set_Argument_Size iFieldLength End Send Initialize_StatusPanel of ghoStatusPanel "AnyFlex" (SFormat("Convert %1", sFieldName)) (If(iMode = CONV_TO_ANSI, "OEM to ANSI", "ANSI to OEM")) Send Start_StatusPanel of ghoStatusPanel Move 0 to Constrain_found_count Move 0 to Constrain_tests_count Move 0 to iChanged Send Request_Read of hDDObj FIRST_RECORD iFile -1 While ((Found) and bStop = False) Get Check_StatusPanel of ghoStatusPanel to bStop If (bStop = False) Begin Get_Field_Value iFile iField to sTestValue If (iMode = CONV_TO_ANSI) Begin Move (ToAnsi(sTestValue)) to sFillValue End Else Begin Move (ToOEM(sTestValue)) to sFillValue End If (sTestValue <> sFillValue) Begin Get BackupFields iFile to sBackupFields Reread iFile Set_Field_Value iFile iField to sFillValue SaveRecord iFile If (not(err)) Increment iChanged Unlock Send RestoreFields iFile sBackupFields End If (Mod(Constrain_found_count, 100) = 0) Begin Send Update_StatusPanel of ghoStatusPanel (SFormat("Records converted: %1 of %2", iChanged, Constrain_tests_count)) End Send Request_Read of hDDObj NEXT_RECORD iFile -1 End Loop Set_Argument_Size iOldArgumentSize Move Constrain_found_count to iCount Send Update_StatusPanel of ghoStatusPanel (SFormat("Records converted: %1 of %2", iChanged, iCount)) Send Refind_Records of hDDObj Send DoPageRefresh Send Update_StatusPanel of ghoStatusPanel "" Send Stop_StatusPanel of ghoStatusPanel Send info_box (SFormat("Records converted: %1 of %2", iChanged, iCount)) End_Procedure // Delete all rows taking the current filters into account. Procedure DoDeleteAllRows String sFieldname Handle hDDObj hCol Boolean bChanged bStop Integer iField iDeleted iFile Integer iAnswer iRecords Get Server to hDDObj If (not(hDDObj)) Procedure_Return Get Should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Get CountFilterRecords to iRecords If (iRecords = 0) Procedure_Return Get YesNo_Box (SFormat("This will delete %1 records from the current filters!\n\nAre you sure?", iRecords)) "WARNING!" MB_DEFBUTTON2 to iAnswer If (iAnswer <> MBR_YES) Procedure_Return Get SelectedColumnObject of oData to hCol Get piBindingColumn of hCol to iField Get piBindingTable of hCol to iFile Send Initialize_StatusPanel of ghoStatusPanel "AnyFlex" "Delete records" "Deleting..." Send Start_StatusPanel of ghoStatusPanel Move 0 to Constrain_found_count Move 0 to Constrain_tests_count Move 0 to iDeleted Send Request_Read of hDDObj FIRST_RECORD iFile -1 While ((Found) and bStop = False) Get Check_StatusPanel of ghoStatusPanel to bStop If (bStop = False) Begin Delete iFile If (not(err)) Increment iDeleted If (Mod(Constrain_found_count, 100) = 0) Begin Send Update_StatusPanel of ghoStatusPanel (SFormat("Records deleted: %1 of %2", iDeleted, iRecords)) End Send Request_Read of hDDObj NEXT_RECORD iFile -1 End Loop Send Update_StatusPanel of ghoStatusPanel (SFormat("Records deleted: %1 of %2", iDeleted, iRecords)) Send MovetoFirstRow of oData Send Update_StatusPanel of ghoStatusPanel "" Send Stop_StatusPanel of ghoStatusPanel Send info_box (SFormat("Records deleted: %1 of %2", iDeleted, iRecords)) 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 Activating String sArgument1 sArgument2 sArgument3 sDir Integer iEngage iFirsttimer iPos Integer iNumArgs iArg iField Handle hoCmdLine hFile Boolean bFound Forward Send Activating Set piFilenumber to 0 Set pbEnabled of oIdleHandler to True Get phoCommandLine of ghoApplication to hoCmdLine Get CountOfArgs of hoCmdLine to iNumArgs If (iNumArgs > 0) Move (ToOEM(Argument(hoCmdLine, 1))) to sArgument1 If (iNumArgs > 1) Move (ToOEM(Argument(hocmdLine, 2))) to sArgument2 If (iNumArgs > 2) Move (ToOEM(Argument(hocmdLine, 3))) to sArgument3 Move (Uppercase(Trim(sArgument2))) to sArgument2 Set psFileName to sArgument1 Case Begin Case (sArgument2 = "RECNUM") Set pbUndersoegFil to True Send StartUpFindRecnum sArgument3 Case Break Case (sArgument2 = "ROWID") Set pbUndersoegFil to True Send StartUpFindRowId sArgument3 Case Break Case (sArgument2 = "NEW") Move 0 to hFile Structure_Start hFile "DATAFLEX" Set_Attribute DF_FILE_PHYSICAL_NAME of hFile to sArgument1 // 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 Set pbUndersoegFil to True Case Break Case Else If (sArgument1 <> "") Set pbUndersoegFil to True Case End End_Procedure // Find a record with recnum when idle. // Used during application startup. Procedure StartUpFindRecnum String sRecnum Boolean bOk Get IsInt sRecnum to bOk If (not(bOk)) Procedure_Return Set piFindRecnum to sRecnum End_Procedure // Find a record with rowid when idle. // Used during application startup. Procedure StartUpFindRowId String sSerializedRowId RowID rwRowId Move (DeSerializeRowId(sSerializedRowId)) to rwRowId Set prwFindRowID to 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 pbFileOpened to False Forward Send Page_delete End_Procedure Procedure DoColumnProperties Integer iFile iField iSelectedFunction Handle hDDObj hStructHandle hCol Boolean bChanged tsColumnProperties lsColumnProperties String sCurrentFile Get Server to hDDObj If (not(hDDObj)) Procedure_Return Get Should_Save of hDDObj to bChanged If (bChanged = True) Procedure_Return Get SelectedColumnObject of oData to hCol Get piBindingColumn of hCol to iField Get piBindingTable of hCol to iFile Get_Attribute DF_FIELD_NAME of iFile iField to lsColumnProperties.sName Get_Attribute DF_FIELD_TYPE of iFile iField to lsColumnProperties.iType If (lsColumnProperties.iType = DF_BCD) Begin Get_Attribute DF_FIELD_PRECISION of iFile iField to lsColumnProperties.iPrecision End Get_Attribute DF_FIELD_LENGTH of iFile iField to lsColumnProperties.iLength Get_Attribute DF_FIELD_OFFSET of iFile iField to lsColumnProperties.iOffset Get EditColumnProperties of oColumnProps (&lsColumnProperties) to iSelectedFunction Case Begin Case (iSelectedFunction = COLUMNPROPS_OK or iSelectedFunction = COLUMNPROPS_NEW) Send DoCloseAllFiles Get psFilename to sCurrentFile Open sCurrentFile as iFile Mode DF_EXCLUSIVE If (Found) Begin Send DoStartResInfo of oResInfo Move iFile to hStructHandle Structure_Start hStructHandle If (iSelectedFunction = COLUMNPROPS_NEW) Begin Move 0 to iField // Always add fields at the end. Create_Field hStructHandle At iField End Set_Attribute DF_FIELD_TYPE of hStructHandle iField to lsColumnProperties.iType If (lsColumnProperties.iType = DF_OVERLAP) Set_Attribute DF_FIELD_OFFSET of hStructHandle iField to lsColumnProperties.iOffset If (lsColumnProperties.iType <> DF_DATE) Set_Attribute DF_FIELD_LENGTH of hStructHandle iField to lsColumnProperties.iLength If (lsColumnProperties.iType = DF_BCD) Set_Attribute DF_FIELD_PRECISION of hStructHandle iField to lsColumnProperties.iPrecision Set_Attribute DF_FIELD_NAME of hStructHandle iField to lsColumnProperties.sName Structure_End hStructHandle DF_STRUCTEND_OPT_NONE "" (oResInfo(Self)) Send DoStopResInfo of oResInfo End Close iFile Set pbUndersoegFil to True Case Break Case (iSelectedFunction = COLUMNPROPS_DELETE) Send DoCloseAllFiles Get psFilename to sCurrentFile Open sCurrentFile as iFile Mode DF_EXCLUSIVE If (Found) Begin Send DoStartResInfo of oResInfo Move iFile to hStructHandle Structure_Start hStructHandle Delete_Field hStructHandle iField Structure_End hStructHandle DF_STRUCTEND_OPT_NONE "" (oResInfo(Self)) Send DoStopResInfo of oResInfo End Close iFile Set pbUndersoegFil to True Case Break Case End End_Procedure // 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(pbFileOpened(Self))) Procedure_Return Get psFilename to sValgtFil If (sValgtFil = "") Procedure_Return Get Server 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 (SFormat('"%1"', sAnyFlexExe)) to sAnyFlexExe Move (SFormat('"%1" ROWID %2', sValgtFil, sSerializedRowId)) to sParam Move (SFormat('"%1"', sAnyFlexPath)) to sAnyFlexPath Send vShellExecute "OPEN" sAnyFlexExe sParam sAnyFlexPath End_Procedure // Modifies the current filelist. Procedure DoModifyFilelist Boolean bFilelistOk If (not(pbFileOpened(Self))) Procedure_Return Get pbFilelistUsed to bFilelistOk If (bFilelistOk) Begin Send DoCloseAllFiles Send Popup_modal of oModifyFilelist Set pbUndersoegFil to True End End_Procedure Procedure DoRecordCount Boolean bReload If (not(pbFileOpened(Self))) Procedure_Return Get DoShowCount of oRecordCount to bReload If bReload Begin Set pbUndersoegFil to True End End_Procedure Procedure DoToggleFullLoad Boolean bFullLoad Handle hoDataSource If (not(pbFileOpened(Self))) Procedure_Return Get pbStaticData of oData to bFullLoad Move (not(bFullLoad)) to bFullLoad Set pbStaticData of oData to bFullLoad Get phoDataSource of oData to hoDataSource Set pbStaticData of hoDataSource to bFullLoad Set pbLoadAll of hoDataSource to bFullLoad Set pbHeaderReorders of oData to bFullLoad Set pbHeaderTogglesDirection of oData to bFullLoad Set Enabled_State of oComboIndex to (not(bFullLoad)) Send DoPaintTheList End_Procedure Object oIdleHandler is a cIdleHandler Procedure OnIdle Boolean bDoUndersoegFil bSetZoom RowID rwRecord Handle hDDObj Integer iFile iRecnum Forward Send OnIdle Get pbSetZomm to bSetZoom If bSetZoom Begin Set pbSetZomm to False Set View_Mode to viewmode_zoom End Get pbUndersoegFil to bDoUndersoegFil If bDoUndersoegFil Begin Set pbUndersoegFil to False Send DoUndersoegFil End Get prwFindRowID to rwRecord If (not(IsNullRowID(rwRecord))) Begin Set prwFindRowID to (NullRowID()) If (pbFileOpened(Self)) Begin Get Server to hDDObj Get piFilenumber to iFile Send FindByRowId of hDDObj iFile rwRecord End End Get piFindRecnum to iRecnum If (iRecnum <> 0) Begin Set piFindRecnum to 0 If (pbFileOpened(Self)) Begin Get Server to hDDObj Get piFilenumber to iFile Send Find_By_Recnum of hDDObj iFile iRecnum End End End_Procedure End_Object Procedure Deactivating Set pbEnabled of oIdleHandler to False Forward Send Deactivating End_Procedure Procedure Entering_Scope Returns Integer Integer iRetVal iViewMode Forward Get msg_Entering_Scope to iRetVal Set pbSetZomm to True Procedure_Return iRetVal End_Procedure End_Object // oEditorView