HISE Logo Forum
    • Categories
    • Register
    • Login

    Expansion - Access AdditionalSourcecode file

    Scheduled Pinned Locked Moved General Questions
    60 Posts 3 Posters 5.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.
    • LindonL
      Lindon @DanH
      last edited by

      @DanH as I said:

      var myObj = Engine.loadFromJSON("somefile");
      if (myObj)
      {
            Console.print(myObj.NumberData);
      }else{
          myObj = {NumberData : 444};
      }
      
      

      HISE Development for hire.
      www.channelrobot.com

      DanHD 1 Reply Last reply Reply Quote 0
      • DanHD
        DanH @Lindon
        last edited by

        @Lindon Thanks, but that will look in the appData folder for the file, whereas I'm in an active expansion.... Or am I getting confused?

        DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
        https://dhplugins.com/ | https://dcbreaks.com/
        London, UK

        d.healeyD DanHD 2 Replies Last reply Reply Quote 0
        • d.healeyD
          d.healey @DanH
          last edited by d.healey

          @DanH You're not confused, but you could just take Lindon's code and adjust it to load from an expansion (and don't use var) :)

              local e = expHandler.getCurrentExpansion();
              local data = e.loadDAtaFile("NewNumber.json");
          
              if (isDefined(data))
              {
                  // Do the thing
              }
              else
              {
                  // Do the other thing
              }
          

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

          DanHD 1 Reply Last reply Reply Quote 0
          • DanHD
            DanH @DanH
            last edited by

            @DanH my takeaway from this is that Engine.loadFromJSON can handle a file not being there but currentexpansion.loadDataFile cannot, and produces an error...

            DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
            https://dhplugins.com/ | https://dcbreaks.com/
            London, UK

            1 Reply Last reply Reply Quote 0
            • DanHD
              DanH @d.healey
              last edited by

              @d-healey yup, but I can't get past .loadDataFile if there's no data file 😆

              HISE doesn't seem to like it (unlike Engine.loadFromJSON)

              DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
              https://dhplugins.com/ | https://dcbreaks.com/
              London, UK

              d.healeyD 1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey @DanH
                last edited by

                @DanH Which line gives the error and what is the error?

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

                DanHD 1 Reply Last reply Reply Quote 0
                • DanHD
                  DanH @d.healey
                  last edited by

                  @d-healey
                  Error:

                  Interface:! Cant find data file {EXP::TEST}NewNumber.json
                  

                  Line:

                  local data = e.loadDAtaFile("NewNumber.json");
                  

                  DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                  https://dhplugins.com/ | https://dcbreaks.com/
                  London, UK

                  d.healeyD 1 Reply Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @DanH
                    last edited by

                    @DanH I see the problem. I've got to go out now but I'll take a look in the HISE source when I get back in a few hours and see if there is an easy fix.

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

                    DanHD 1 Reply Last reply Reply Quote 0
                    • DanHD
                      DanH @d.healey
                      last edited by

                      @d-healey ok thanks!

                      DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                      https://dhplugins.com/ | https://dcbreaks.com/
                      London, UK

                      d.healeyD 1 Reply Last reply Reply Quote 0
                      • d.healeyD
                        d.healey @DanH
                        last edited by d.healey

                        This is how Engine.loadFromJSON handles a missing file.

                        4b5e1a15-ec98-4b6e-ac2a-8016f94fcd3d-image.png

                        And this is how loadDataFile handles it:

                        5f809006-6dd4-4d00-a604-c9528daa6be6-image.png

                        So it reports an error but does it actually stop the rest of your script running? In other words, if you put Console.print("HELLO WORLD"); on the next line does anything print to the console?

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

                        DanHD 1 Reply Last reply Reply Quote 0
                        • DanHD
                          DanH @d.healey
                          last edited by

                          @d-healey yeah it stops it - i.e no "Hello World"

                          DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                          https://dhplugins.com/ | https://dcbreaks.com/
                          London, UK

                          d.healeyD 1 Reply Last reply Reply Quote 0
                          • d.healeyD
                            d.healey @DanH
                            last edited by

                            @DanH Okay, I think we should make it so it behaves the same as loadFromJSON and leave it up to the scripting to validate the file. I'll make a pull request with this later.

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

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

                              @DanH Yeah removing those lines makes it work like the other function which I think is much better behaviour. I've made a pull request and the change is also in my fork.

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

                              DanHD 1 Reply Last reply Reply Quote 0
                              • DanHD
                                DanH @d.healey
                                last edited by

                                @d-healey great, so just remove the reportScriptError line?

                                DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                https://dhplugins.com/ | https://dcbreaks.com/
                                London, UK

                                d.healeyD 1 Reply Last reply Reply Quote 0
                                • d.healeyD
                                  d.healey @DanH
                                  last edited by d.healey

                                  @DanH Just do what I did - https://github.com/christophhart/HISE/pull/286/commits/3ebdf557839a53c2d94c123e72391b62919aa725 (the red stuff is the parts I deleted)

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

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

                                  50

                                  Online

                                  1.7k

                                  Users

                                  11.7k

                                  Topics

                                  101.8k

                                  Posts