Forum

    • Register
    • Login
    • Search
    • Categories

    Opening a .pdf file or specific folder

    General Questions
    5
    27
    165
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Steve Mohican last edited by Steve Mohican

      Is it possible to open a folder that is located in the "Program Files" on Windows & the "Applications" on the Mac?

      ustk 1 Reply Last reply Reply Quote 0
      • ustk
        ustk @Steve Mohican last edited by ustk

        @Steve-Mohican You should be able to use an absolute path.
        Absolute paths can be dangerous but unless I'm wrong I don't think it is bad here...

        Tired to press F5 in the forum...
        Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

        S 1 Reply Last reply Reply Quote 1
        • S
          Steve Mohican @ustk last edited by

          @ustk I am trying .fromAbsolutePath but no luck.

          const var Button1 = Content.getComponent("Button1");
          
          inline function onButton1Control(component, value)
          {
          	if (value)
          	{	
          		if (Engine.getOS() == "OSX")		
          		FileSystem.fromAbsolutePath("/Applications");
          		
          		else if (Engine.getOS() == "WIN")		
          		FileSystem.fromAbsolutePath("c:\Program Files");
          	}
          	
          };
          
          Content.getComponent("Button1").setControlCallback(onButton1Control);
          
          
          
          
          ustk 1 Reply Last reply Reply Quote 0
          • Topic has been marked as a question  S Steve Mohican 
          • ustk
            ustk @Steve Mohican last edited by

            @Steve-Mohican

            inline function onButton1Control(component, value)
            {
            	if (value)
            		FileSystem.browseForDirectory(FileSystem.fromAbsolutePath("/Applications"), doSomething);
            };
            Content.getComponent("Button1").setControlCallback(onButton1Control);
            
            
            function doSomething(dir)
            {
            	Console.print(dir.toString(0));
            }
            

            Tired to press F5 in the forum...
            Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

            S 1 Reply Last reply Reply Quote 2
            • S
              Steve Mohican @ustk last edited by

              @ustk Oh that's great, opens the browser, but it doesn't allow you to open a file.
              What about only for browsing? Actually my goal is to open a .pdf file.

              d.healey 1 Reply Last reply Reply Quote 0
              • d.healey
                d.healey @Steve Mohican last edited by

                @Steve-Mohican said in Opening a specific folder:

                What about only for browsing? Actually my goal is to open a .pdf file.

                https://docs.hise.audio/scripting/scripting-api/filesystem/index.html#browse

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

                S 1 Reply Last reply Reply Quote 1
                • S
                  Steve Mohican last edited by

                  Thank you guys, I will check it out!

                  1 Reply Last reply Reply Quote 0
                  • Topic has been marked as solved  S Steve Mohican 
                  • Topic has been marked as unsolved  S Steve Mohican 
                  • S
                    Steve Mohican @d.healey last edited by Steve Mohican

                    @d-healey I prefer using the classic .pdf manuals, not interested in the Markdown stuff for now.

                    I watched the tutorial and looked into the FileSystem & File APIs.

                    I think we can't add a button like below - "Open Manual" button that opens the .pdf file directly. Or at least open the manual directory with a browser, and the user can select the manual and open it, I could live with that too.

                    alt text

                    d.healey 1 Reply Last reply Reply Quote 0
                    • Topic is now a regular thread  S Steve Mohican 
                    • d.healey
                      d.healey @Steve Mohican last edited by

                      @Steve-Mohican You might be able to open it directly with File.startAsProcess() but I've not tested it, and you'll have to handle the situation where the file isn't where you expect it.

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      S 1 Reply Last reply Reply Quote 1
                      • S
                        Steve Mohican @d.healey last edited by

                        @d-healey said in Opening a .pdf file or specific folder:

                        @Steve-Mohican You might be able to open it directly with File.startAsProcess() but I've not tested it, and you'll have to handle the situation where the file isn't where you expect it.

                        I think it can be handled with isFile. But first of all below one doesn't trigger the UserManual.pdf on my desktop.

                        const var Button1 = Content.getComponent("Button1");
                        
                        const FindFolder = FileSystem.getFolder(FileSystem.Desktop);
                        const FindFile = FindFolder.getChildFile("UserManual.pdf");
                        
                        inline function onButton1Control(component, value)
                        {
                        	if (value)
                        	{
                        		local f = FindFile.toString(1);
                        		File.startAsProcess(FindFile.toString(1));
                        	}
                        	
                        };
                        
                        Content.getComponent("Button1").setControlCallback(onButton1Control);
                        
                        
                        d.healey 1 Reply Last reply Reply Quote 0
                        • d.healey
                          d.healey @Steve Mohican last edited by

                          @Steve-Mohican said in Opening a .pdf file or specific folder:

                            File.startAsProcess(FindFile.toString(1));
                          

                          Yup that won't work. You need to read the API doc.

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          S 1 Reply Last reply Reply Quote 0
                          • S
                            Steve Mohican @d.healey last edited by

                            @d-healey

                            Yup that won't work. You need to read the API doc.

                            Doc says File.startAsProcess(String parameters) So I need that String parameter right?

                            So I tried to convert the folder path to the string with toString

                            d.healey orange 2 Replies Last reply Reply Quote 0
                            • d.healey
                              d.healey @Steve Mohican last edited by

                              @Steve-Mohican File in this instance means the file object that you want to open, not the File class. Parameters is for when you're opening a CLI application and want to pass in some values, generally you'll just set this to ""

                              So what you'll want is something like f.startAsProcess("");

                              Libre Wave - Freedom respecting instruments and effects
                              My Patreon - HISE tutorials
                              YouTube Channel - Public HISE tutorials

                              1 Reply Last reply Reply Quote 2
                              • orange
                                orange @Steve Mohican last edited by orange

                                @Steve-Mohican

                                If you want to use the absolute paths for addressing the manuals, you also need to check the operating systems. Another thing to mention is the macOS will want the user to grant the access to the dedicated folders. Below one should work:

                                
                                const var Button1 = Content.getComponent("Button1");
                                
                                inline function onButton1Control(component, value)
                                {
                                	if (value)
                                	{
                                		if (Engine.getOS() == "OSX")
                                		{
                                			local FindFileforMac = (FileSystem.fromAbsolutePath("/Applications/MyCompany")).getChildFile("User manual.pdf");
                                
                                			if (FindFileforMac.isFile()) FindFileforMac.startAsProcess("");		
                                		}
                                
                                
                                		else if (Engine.getOS() == "WIN")
                                		{
                                			local FindFileforWin = (FileSystem.fromAbsolutePath("C:\Program Files\MyCompany")).getChildFile("User Manual.pdf");
                                			
                                			if (FindFileforWin.isFile()) FindFileforWin.startAsProcess("");					
                                		}
                                		
                                		else Console.print("The User Manual can't be found");
                                
                                	}
                                	
                                };
                                
                                Content.getComponent("Button1").setControlCallback(onButton1Control);
                                
                                
                                S Jay 2 Replies Last reply Reply Quote 3
                                • S
                                  Steve Mohican @orange last edited by Steve Mohican

                                  @orange Wow Thanks! I've just tried and it works great.

                                  I appreciate all of your help guys!

                                  1 Reply Last reply Reply Quote 1
                                  • Jay
                                    Jay @orange last edited by

                                    @orange it is saying function not found on "if (FindFileforMac.isFile()) FindFileforMac.startAsProcess("");"

                                    Joansi Villalona

                                    orange 1 Reply Last reply Reply Quote 0
                                    • orange
                                      orange @Jay last edited by orange

                                      @Jay This works here with the current develop branch. You need to handle the folder paths and also file name - extension in the .getChildFile properly.

                                      HiseSnippet 1026.3ocwV89aaTCF1WaNzt.Lwj3qHYkO.Wj1RSXC1DnJZZZBJhkz.oqae.oMm67kXUe1mr8MHBUI9Sl+CfW66RxkRZ2TDSDojn2e5G+3W+95IJYDUqkJjWvEKynHuOwe5RgYQuEDl.M7Lj288GQzFpBWn5zkYDslFi77N7GsJ7Bpgbe9qe3TBmHhnaTgPWJYQzmyRYlMZmbxOw37AjX5ErzJd+jSFFIE8jbYNfmC8aixHQWQlSGSrtcfOx6i5GyLR0TCwP0HuZmJiWNcg72DE9eISylwoVgNnoPhJTOPxisH1pE0aAiGOY09VifrLYCKbXAK749iXwr052vFely.dSDU4CuC1FdGtE75TEdsq.uc.IuJPpVAjdf+zHEKyrwhEOer+PAb3jP.ZuJTJ7EcvWTyumD7PXZkRthNPABqiH7wsa+PL7Syuud85.2qM32RT3SyMFonC9X7pXmSM8joYRAHD1nzdCaXLAmIn3jbQjgIEXonzpMTkjGFsJtGB4lmSaV+OpGvRvgkRAfnStuXNjI6Rc9zvl3iOF237oupA3gyk.tLhvwCXh3ALNMQpFQh.HFZkltDJQSaknjocmok7bCcBwrHrwQcyx3rHhEa5iFKYZZW8hiFSowvliyoNTeTilMc6Q6AgMegMbd7rNVF.xGE2+mwOB+BMbOXDQjC.4KwOGJsEZlXNt6bEklZIpr3DKs.v090ts1FvsXZW9a17F6jVZCQY5pKOdCa.ooHKWCmMAATtlhuEZ5kCGeGzzKYh2IM0669UXgmqHoXqeaXJb27Xl7+I9BP9t4KqgcyWqnL2eNNqDPsxTLas6EKnaAqHh3qL3YPErLWDaSRca30uFpseGU+szV8tp7dDNeFzrJ7lk+taVUtbLVZnmKBcWBpecc7MMkjrSakYiSU6zrsOp5tBLTjmNippdEz5HzbY6NV92dGqpMTiJHlJNJECELy4YTws0lEUxl1taknBb035sc+xdaEbGhAsvB7KIRjCxUmofdwvyHFxpDA4DVmLpxvraAuynuEJzJZZF3eFUekQl47s7HD1luGK6uudI+yKOY4Zg27lSX5QRawKQAp8N.8u6UCSIjw4bhY6QG14kkFfSms5Wa6IC2MLKqNO8+r4IuuP7A9SXlnE6FiGrCLBmAeHvX4T3O0ueRBzwYC.q4O3UeXF4h9EYtA5MMhXTL3r2ebd5T3gHQTX0EBnUBnCNrsg5jaaksLvTpH1I72vmRicrxdkF6rxHJkDojuNpn52Nm+dNM.lDtm3D.u0BjwqK588a2pMJEdxwqihra+GAWs1cLe8dDyi2iXdxdDy2rGw7s6QLOcOh4Y2YL1W60M2HSKtN.Jlz207wyquf.UVtpPz+.akvxn
                                      
                                      Jay 3 Replies Last reply Reply Quote 0
                                      • Jay
                                        Jay @orange last edited by

                                        @orange I compile the new develop branch and it works, thanks

                                        Joansi Villalona

                                        1 Reply Last reply Reply Quote 0
                                        • Jay
                                          Jay @orange last edited by

                                          @orange The only issue I have now, in HISE it open but it doesn't open within the compile plugin. It open in HISE but not in plugin

                                          Joansi Villalona

                                          orange 1 Reply Last reply Reply Quote 0
                                          • orange
                                            orange @Jay last edited by orange

                                            @Jay Where did you locate the .pdf file? AppData folder? Send your modified snippet.

                                            Jay 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            6
                                            Online

                                            740
                                            Users

                                            5.4k
                                            Topics

                                            50.4k
                                            Posts