HISE Logo Forum
    • Categories
    • Register
    • Login

    How to check if a json file is not in the project folder

    Scheduled Pinned Locked Moved Solved General Questions
    13 Posts 3 Posters 591 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.
    • S
      Sawer @d.healey
      last edited by

      @d-healey But why when I remove the Json file from my folder, the onInit callback console doesn't give me error stating that there's no variable or Json file? Cause I have a statement that works on a value placed in a Json data. When I throw the Json file to the trash, the function still works on that value.

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

        Can you show me a code example?

        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
          Sawer @d.healey
          last edited by

          @d-healey

          inline function checkOnLoad()
          {
          	local pData = Engine.loadFromJSON("../endTrial.js");
                  
                  local v = pData.enddate;
                  
                  if (todaystime > v )
                  {
          		  include("Serials.js");
          		  include("Authorisation.js");
                    ScriptLabel3.showControl(false);
          		  AuthorisationDialogue.showControl(1);
          		  GlobalMute.setAttribute(GlobalMute.ignoreButton, 1);
          
                   }
                  
                  else if (todaystime < v)
                  {
                     Console.print("trial still working"); 
                     ScriptLabel3.setValue("10 Day Trial Running");
                     AuthorisationDialogue.showControl(0);
                     Label1.showControl(0);
                     Startbtn.showControl(0);
                     GlobalMute.setAttribute(GlobalMute.ignoreButton, 0);
                  }
                  
                  ScriptLabel3.changed();
                  
                  
              
          }
          
              checkOnLoad();
          

          My concern is that the " local v = pData.enddate;" still works even when it's not there (Json File throwed away) That's why I was looking for a function to check if the Json is in the project folder so the whole function resets. The purpose behind my question is that I want to create a set of function that :

          1. On a button callback, dumpsAsJson(myData,"/..myFile)
          2. If myVar is > or < than myData = Do something
          3. If Json file is not there = reset UI to state 1
          d.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @Sawer
            last edited by

            @Sawer

            You're including files within a function, does that work?

            How are you checking if the data is being loaded from the file?

            How are you getting todaystime?

            To check the existence of a file you should use the file and filesystem APIs.

            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
              Sawer @d.healey
              last edited by Sawer

              @d-healey Everything works perfectly.
              I just need a function that checks if a file is there or not So that the UI (label1 and Startbtn) is or is not visible based on my statements.
              The snippet has other files outside, so you could probably get a lot of errors. Let me try and send it then..

              HiseSnippet 2526.3oc2Y8tbabaD+NIcolzxwNYxj1OhQSmoTMpTjRT+Kt0gRhTNLQThiHsS8zYZJ3QPRDcD3xc3jLaF2wSeR5iheD5iPeDxaf6Bb2oCG4QZZNMcZ58AagE6t3GVr6hcAa4wsI99bOCybcF6RLLW2p8XlX3oCwTlQiZFlOx5Tt63VdbAwVP4LiSF6h88I8LLMW8oRtLyslg56G+hSvNXlMIgjgwy4Tax4zQTQB0VU+ZpiyY3djNzQZbWoZCaN6TtCO.PzpVkLbw1WiGPt.KYaEKCyOndOpf60VfEDeCy0Ng2ab6g7aYg7+bpOsqCQNnrQaPQgjOi6zShXIUiSGRc50Jdm6aXXZ0JwNrZnc3SrZR6Quitt8PNAJQBc6g4Jog2pofWYc3URCdY.oUzfzZgP5irZa6QcEIyHwy8sZvDDu9XvrqCkPdMVwXc3.D3fIJNBeM4LOXvcRTX+Rk1BsWoRa9374yu81mEvTGxHwPr.MfH9M9nN7d3w9ndvNpPsZa2r41u.91LOk4PYDT+XQ.tkmlvVejaCVMPlBRYZK7nrAal+GxifOGtM1AIh4C8GPMwhgE83ArdZrWzOnqu5uJr+VnC2bSTz21aijZNOJiuO6cpqJag1Gz0uEsao6TWSvdLbYUHX7pDpv826wQJ7EDrW9bxOkR8Hh.OVxV9wJp4ekzbWCzI5JRehGAhZ7yCN+9BzMXuHitbMASTc1.vRWDLvsG6KHijl4B8wN9D3XKQl5rdyS.gWPZ9Ep0P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Zdye8k+CicuaC8ZqdTO0h+opwnuQ93EOkvHdRiW447Sx7OWzeRF2E9mjIr9uNPcZ9tb+TJtMYDsCjLQu.CCYAUdjuWU8lN8SgJoxbpe7KNC1jYJSarHvS4Vb7Hd.SjxMX048SCUdI+ogV6+49og9YPvtoYqo9gEeD35Nx0gTmcCwA5DTgwO1Jpz+Xpo8kaxYb2gbF0V+f9JBzz+fADOcrm4F5Xg.ZcHgxmT8JhCAq6z9qqdN3rg8jMNrj1hxKtsXdmW+JqP3hjAfne9ljd0++NI8U7.YK9MwfSHTKjEzHbaH2nMIpSO4CrXthL+V33RxwgIGY8TCdK7EMYY4XynIKGO4+UViQXaO92ZGV8gzO8dJJv9lo9w1yY0TNFUNtbCKqREKYLBxv8s11RS7uCRXlsL6rDxr6RHSkkPl8VBY1eIj4fkPlCmqLxKWfVh3ih5oznYq5pWswzrNCCduJOci+MvGNZVo
              
              d.healeyD LindonL 2 Replies Last reply Reply Quote 0
              • d.healeyD
                d.healey @Sawer
                last edited by d.healey

                @Sawer Use the file api. You should answer the questions I asked and I might be able to help you more.

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

                S 1 Reply Last reply Reply Quote 1
                • LindonL
                  Lindon @Sawer
                  last edited by

                  @Sawer

                  Have you tried:

                  local pData = Engine.loadFromJSON("../endTrial.js");
                  if (pData)
                  {
                      Console.print("file loaded...");
                  }else{
                      Console.print("file NOT THERE.....");
                  }
                  

                  HISE Development for hire.
                  www.channelrobot.com

                  S 1 Reply Last reply Reply Quote 3
                  • S
                    Sawer @Lindon
                    last edited by

                    @Lindon Not yet, trying it now. Thanks so much.

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

                      @d-healey
                      I've tried with the api, but maybe I haven't found precisely what I was looking for. Anyway I've attached the snippet, this will answer all the question. Thanks

                      S 1 Reply Last reply Reply Quote 0
                      • S
                        Sawer @Sawer
                        last edited by

                        @d-healey , @Lindon Working super, thanks so much for the help!

                        1 Reply Last reply Reply Quote 1
                        • S Sawer has marked this topic as solved on
                        • First post
                          Last post

                        15

                        Online

                        1.7k

                        Users

                        11.9k

                        Topics

                        103.3k

                        Posts