//AB/ Project Brug_Filelist
//AB/ Object oIDE_Project is a Lookup_Project
    //AB/ Set Size to 221 367
    //AB/ Set ProjectName to "Brug_Filelist"
    //AB/ Set ProjectFileName to "Brug_Filelist.SL"
    //AB/ Set GenerateFileName to "NONAME5"

// Project Object Structure
//   Brug_Filelist is a dbModalPanel
//     oSellist is a List
//     oOK_bn is a Button
//     oAnnuller_bn is a Button
//     oFilelistSti is a Array

// Register all objects
Register_Object Brug_Filelist
Register_Object oAnnuller_bn
Register_Object oFilelistSti
Register_Object oOK_bn
Register_Object oSellist

//AB-IgnoreStart
Use dfdbmdpn.pkg
Use Windows.pkg
//AB-IgnoreEnd



Object Brug_Filelist is a dbModalPanel

    //AB-StoreTopStart
    Property String psValgtReg Public ""
    
    //AB-StoreTopEnd

    Set Label to "Choose databasefile from filelist.cfg"
    Set Location to 4 5
    Set Size to 153 297

    //AB-DDOStart


    //AB-DDOEnd

    Object oSellist is a List

        //AB-StoreTopStart
        
        //AB-StoreTopEnd

        Set Size to 101 285
        Set Location to 4 4
        Set peAnchors to anAll

        //AB-StoreStart
        
        Procedure DoFillList
            String Rootname Besked Displayname Logicalname sStinavn sPhysicalName
            Integer Filenum iMaxRec iNumRec StructHandle iNyMaxRec
            Integer maxFilelist iOldStd
            Boolean bDisplayFile
            Get dynamic_update_state to iOldStd
            Set dynamic_update_state to False
        
            Send Delete_Data
            Send Delete_Data to oFilelistSti
        
            Move 0 to maxFilelist
            Move 0 to Filenum   //Start at top of current filelist
            Repeat
                Get_Attribute DF_FILE_NEXT_USED of FileNum to FileNum
                If Filenum Begin
                    Get_Attribute DF_FILE_ROOT_NAME of FileNum to Rootname
                    Get_Attribute DF_FILE_DISPLAY_NAME of FileNum to Displayname
                    If (Uppercase(Trim(Rootname)) <> "FLEXERRS") Begin
                        Move Filenum to besked
                        Append besked ", " Displayname ", " Rootname
                        Send Add_item 0 besked
                        Set array_value of oFilelistSti Item maxFilelist to FileNum
                        Increment maxFilelist
                    End
                End
            Until (FileNum = 0)
            Set dynamic_update_state to iOldStd
        
        End_Procedure  // DoFillList
        
        //Procedure OnChange
        //    Integer iCurrent
        //    Get Current_item to iCurrent // item number of current item
        //
        //End_Procedure  // OnChange
        
        Procedure Ok
            String sValgt
            Integer iItem Filenum
            Get current_item to iItem
            Get Integer_value of oFilelistSti Item iItem to FileNum
            Send ignore_all to error_info_object
            Open FileNum
            If (Found) Begin     //Det lykkedes at †bne filen
                Get_Attribute DF_FILE_ROOT_NAME of Filenum to sValgt
                If (sValgt = "") Begin
                    Get_Attribute DF_FILE_PHYSICAL_NAME of FileNum to sValgt
                End
            End
            Else Begin
                Move "" to sValgt
            End
            Close FileNum
            Send trap_all to error_info_object
            If (sValgt = "") Send info_box "Cannot open this databasefile."
            Else Begin
                Set psValgtReg to sValgt
                Set piFileNumber to FileNum
                Send Request_cancel
            End
        End_Procedure
        
        Procedure Cancel
            Send Request_cancel
        End_Procedure
        
        Procedure Mouse_click Integer iW Integer iP
            Forward Send Mouse_click iW iP
            Send Ok
        End_Procedure
        
        //AB-StoreEnd

    End_Object    // oSellist

    Object oOK_bn is a Button
        Set Label to "&Ok"
        Set Location to 114 181
        Set peAnchors to anBottomRight

        //AB-StoreStart
        Procedure OnClick
            Send OK to oSelList
        End_Procedure
        //AB-StoreEnd

    End_Object    // oOK_bn

    Object oAnnuller_bn is a Button
        Set Label to "&Cancel"
        Set Location to 114 235
        Set peAnchors to anBottomRight

        //AB-StoreStart
        Procedure OnClick
            Send Cancel to oSelList
        End_Procedure
        //AB-StoreEnd

    End_Object    // oAnnuller_bn

    Object oFilelistSti is a Array
        //AB/ Set Location to 110 135
    End_Object    // oFilelistSti


    //AB-StoreStart
        
    On_Key Key_Alt+Key_O Send KeyAction to oOk_bn
    On_Key Key_Alt+Key_C Send KeyAction to oAnnuller_bn
    On_Key key_escape Send Cancel of oSellist
    On_Key kEnter Send Ok of oSellist
    
    Procedure Activate_group
        Set visible_state to False
        Forward Send Activate_Group
        Send DoFillList of oSellist
        Set psValgtReg to ""
        Set visible_state to True
    End_Procedure
    
    
    
    
    //AB-StoreEnd

End_Object    // Brug_Filelist

//AB/ End_Object    // oIDE_Project
