Topic
6 replies Latest Post - ‏2014-03-13T13:52:02Z by KBSri
KBSri
KBSri
104 Posts
ACCEPTED ANSWER

Pinned topic Browse button code inbuilt in DXL

‏2014-03-13T06:17:34Z |

Can any one please let me know where the in-built code for Browse which we use in DXL is located?

Thanks a ton in advance.

  • M_vdLaan
    M_vdLaan
    27 Posts
    ACCEPTED ANSWER

    Re: Browse button code inbuilt in DXL

    ‏2014-03-13T08:54:36Z  in response to KBSri

    Hi KBSri,

     

    The question's not very clear unfortunately, but I'll have a go at answering it...

    Assuming you're looking to browse for a file on the disk or on the network, you probably need to check out the fileName DBE:

    DBE fileName(DB box,
                [string label,]
               [,string initFileName
               [,string extension,
                 string description
                 [,bool readOnly]]]) 
    

    Where the actual code is located, I don't know... But I'm guessing it's hidden in an encrypted .inc file.

     

    If you need to browse the database, then I'm afraid you will have to create a custom button and add a database explorer. There's nothing built-in for that.

     

    Hope this helps.

     

    Marcel

    • KBSri
      KBSri
      104 Posts
      ACCEPTED ANSWER

      Re: Browse button code inbuilt in DXL

      ‏2014-03-13T09:25:43Z  in response to M_vdLaan

      Let me precise in my question. I have function for BROWSE button.

      The function is:

      DBE dbeBrowse = null

      void doBrowse(DBE db)
      {
      string getWindowsFolder(string &dirPath)
      {
      OleAutoObj objDialog = null
      OleAutoObj objFolder = null
      OleAutoObj objFolderItem = null
      OleAutoArgs args = create

      string folderPath = ""
      string res = ""

      dirPath = ""

      objDialog = oleCreateAutoObject("Shell.Application")

      if (null objDialog)
      {
      return("Failed to create dialog object")
      }

      put(args, 0) // always zero
      put(args, "Please select a folder") // title
      put(args, 0) // options
      //put(args, "c:\\temp") // root folder

      res = oleMethod(objDialog, "BrowseForFolder", args, objFolder)

      if (null objFolder)
      {
      if (res "" != "")
      {
      return("Failed to launch browser: " res)
      }
      else
      {
      return("")
      }
      }

      res = oleGet(objFolder, "Self", objFolderItem)

      if (null objFolderItem)
      {
      return("Failed to get folder item: " res)
      }

      oleGet(objFolderItem, "Path", folderPath)

      dirPath = folderPath

      return(res)
      }

      The problem here is I am confused to store the function value inside the DBE Button here.

      I have called the particular function inside main() as : dbeBrowse = button(dbRunAll,"Browse", doBrowse)

      The requirement is that if we run the script it should pop a Dialog Box and then in that there should be Button exists for BROWSE where the user can select the file from the required directory.

      I am stuck with this.Any help is appreciated in this.

      • M_vdLaan
        M_vdLaan
        27 Posts
        ACCEPTED ANSWER

        Re: Browse button code inbuilt in DXL

        ‏2014-03-13T11:42:59Z  in response to KBSri

        Okay, so you want the doBrowse callback to show a folder selection window. From there you want to store the path that was returned and have the script use it. 

        As I see it, you can either make dirPath a global variable and store the path there, or you could add a text field next to the Browse button, for example, and set the value of the field when the doBrowse completes. You can even choose to maken that field read-only so it can only be set through the folder selection dialog, but the result can be seen afterwards. Try this and let us know if this is what you need.

         

        DB dbMain
        DBE dbeBrowse
        DBE dbeFolder
        
        void doBrowse(DBE db)
        {
            OleAutoObj objDialog = null
                OleAutoObj objFolder = null
                OleAutoObj objFolderItem = null
                OleAutoArgs args = create
        
                string folderPath = ""
                string res = ""
        
                objDialog = oleCreateAutoObject("Shell.Application")
        
                if (null objDialog) {
                        print "Failed to create dialog object"
                }
        
                put(args, 0) // always zero
                put(args, "Please select a folder") // title
                put(args, 0) // options
                //put(args, "c:\\temp") // root folder
        
                res = oleMethod(objDialog, "BrowseForFolder", args, objFolder)
        
                if (!null res) {
                        print "Failed to launch browser: " res "\n"
                        return
                }
        
                res = oleGet(objFolder, "Self", objFolderItem)
        
                if (!null res) {
                        print("Failed to get folder item: " res)
                        return
                }
        
                res = oleGet(objFolderItem, "Path", folderPath)
                if (!null res) {
                        print "Error getting path: " res "\n"
                        return
                }
        
                set(dbeFolder, folderPath)
        
                oleCloseAutoObject objDialog
        
                return
        }
        
        void doOk(DB db){
                string sFolder = get(dbeFolder)
                infoBox(dbMain, "You selected the folder " sFolder )
        }
        
        void main()
        {
                dbMain = create("Folder selection test")
                dbeFolder = field(dbMain, "Folder", "Bla", 60, true)
                dbeBrowse = button(dbMain, "Browse...", doBrowse)
                dbeBrowse->"left"->"flush"->dbeFolder
                dbeBrowse->"top"->"aligned"->dbeFolder
                ok(dbMain, doOk)
                realize dbMain
                show dbMain
        }
        
        main()
        

         

        • KBSri
          KBSri
          104 Posts
          ACCEPTED ANSWER

          Re: Browse button code inbuilt in DXL

          ‏2014-03-13T12:13:46Z  in response to M_vdLaan

          Amazing!! Thanks a ton!Jus have one doubt here...

          This is selecting only the folder here...incase if you want to select a file.

          You have any suggestions on that?

          • M_vdLaan
            M_vdLaan
            27 Posts
            ACCEPTED ANSWER

            Re: Browse button code inbuilt in DXL

            ‏2014-03-13T13:20:16Z  in response to KBSri

            I thought the whole object of the game was to select a folder only... I thought that's why you jumped through the OLE hoops...

            Selecting a single file is much easier (and built in):

            DB dbMain
            DBE dbeFile
            
            void doOk(DB db){
                string sFile = get(dbeFile)
                infoBox(dbMain, "You selected the file " sFile )
            }
            
            void main()
            {
                dbMain = create("Folder selection test")
                dbeFile = fileName(dbMain, "File", "")
                ok(dbMain, doOk)
                realize dbMain
                show dbMain
            }
            
            main()
            

             

            That's why I mentioned it in my first post.

             

            Enjoy!

             

            Marcel

            Updated on 2014-03-13T13:23:16Z at 2014-03-13T13:23:16Z by M_vdLaan
            • KBSri
              KBSri
              104 Posts
              ACCEPTED ANSWER

              Re: Browse button code inbuilt in DXL

              ‏2014-03-13T13:52:02Z  in response to M_vdLaan

              You are simply awesome!!