HISE Logo Forum
    • Categories
    • Register
    • Login

    Opening a .pdf file or specific folder

    Scheduled Pinned Locked Moved General Questions
    27 Posts 5 Posters 1.4k Views
    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.
    • ?
      A Former User
      last edited by A Former User

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

      ustkU 1 Reply Last reply Reply Quote 0
      • ustkU
        ustk @A Former User
        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...

        Can't help pressing F5 in the forum...

        ? 1 Reply Last reply Reply Quote 0
        • ?
          A Former User @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);
          
          
          
          
          ustkU 1 Reply Last reply Reply Quote 0
          • System marked this topic as a question on
          • ustkU
            ustk @A Former User
            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));
            }
            

            Can't help pressing F5 in the forum...

            ? 1 Reply Last reply Reply Quote 1
            • ?
              A Former User @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.healeyD 1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey @A Former User
                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.

                Link Preview Image
                HISE | Scripting | FileSystem

                The API class for accessing the file system in HISEScript

                favicon

                (docs.hise.audio)

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

                ? 1 Reply Last reply Reply Quote 0
                • ?
                  A Former User
                  last edited by

                  Thank you guys, I will check it out!

                  1 Reply Last reply Reply Quote 0
                  • System has marked this topic as solved on
                  • System has marked this topic as unsolved on
                  • ?
                    A Former User @d.healey
                    last edited by A Former User

                    @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.healeyD 1 Reply Last reply Reply Quote 0
                    • System marked this topic as a regular topic on
                    • d.healeyD
                      d.healey @A Former User
                      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

                      ? 1 Reply Last reply Reply Quote 0
                      • ?
                        A Former User @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.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          d.healey @A Former User
                          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

                          ? 1 Reply Last reply Reply Quote 0
                          • ?
                            A Former User @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.healeyD orangeO 2 Replies Last reply Reply Quote 0
                            • d.healeyD
                              d.healey @A Former User
                              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 1
                              • orangeO
                                orange @A Former User
                                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);
                                
                                

                                develop Branch / XCode 13.1
                                macOS Monterey / M1 Max

                                ? JayJ 2 Replies Last reply Reply Quote 2
                                • ?
                                  A Former User @orange
                                  last edited by A Former User

                                  @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
                                  • JayJ
                                    Jay @orange
                                    last edited by

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

                                    Joansi Villalona

                                    orangeO 1 Reply Last reply Reply Quote 0
                                    • orangeO
                                      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
                                      

                                      develop Branch / XCode 13.1
                                      macOS Monterey / M1 Max

                                      JayJ 3 Replies Last reply Reply Quote 0
                                      • JayJ
                                        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
                                        • JayJ
                                          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

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

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

                                            develop Branch / XCode 13.1
                                            macOS Monterey / M1 Max

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

                                            21

                                            Online

                                            1.8k

                                            Users

                                            11.9k

                                            Topics

                                            104.0k

                                            Posts