HISE Logo Forum
    • Categories
    • Register
    • Login

    Can you add line number for error "You must specify the unique component name, not the object itself”?

    Scheduled Pinned Locked Moved Scripting
    7 Posts 3 Posters 302 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.
    • F
      Fergler
      last edited by

      This error has chased me for ages and I know what chunk of code it belongs to but can’t find a fix.

      function createPreset(displayName, target, parent, column, row, preset) {
      	reg qsW = 120;
      	reg qsH = 22;
      	reg margin = 5;
      
      	reg qsX = margin + column * (qsW + margin);
      	reg qsY = margin + row * (qsH + margin);
      	reg qsBg = 0x11FFFFFF;
      
      	reg qsItem = Content.addPanel("qs" + target, 10 + qsX, 10 + qsY);
      	Content.setPropertiesFromJSON("qs" + target, {
      		"parentComponent": parent,
      		"text": [displayName, target, preset],
      		"width": qsW,
      		"height": qsH,
      		"allowCallbacks": "Clicks & Hover",
      	});
      
      Christoph HartC d.healeyD 2 Replies Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart @Fergler
        last edited by

        @Fergler parent must be a string, not a reference to the UI object

        Christoph HartC 1 Reply Last reply Reply Quote 0
        • Christoph HartC
          Christoph Hart @Christoph Hart
          last edited by

          And if the script error doesn't contain the line information (some errors appear in a context that doesn't know about the scripting code), you can always use the assertion methods from the Console to get a nice stack trace:

          inline function call2(parent)
          {
          	Console.assertEqual(typeof(parent), "string");
          }
          
          function call1(p)
          {
          	call2(p);
          }
          
          const var k = Content.addKnob("k", 0, 0);
          
          call1("1234");
          call1(k);
          

          yields:

          Master Chain:! Assertion failure: values are unequal {SW50ZXJmYWNlfG9uSW5pdCgpfDg5fDd8MjE=}
          :			call2() - Line 7, column 21	{SW50ZXJmYWNlfG9uSW5pdCgpfDg5fDd8MjE=}
          :			onInit() - Line 12, column 2	{SW50ZXJmYWNlfHwxMzZ8MTJ8Mg==}
          
          1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @Fergler
            last edited by

            @Fergler Why are you using a function and not an inline function?

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

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

              Parent is a string, I should have included my function call:

              Quickset.createPreset("Close Skins", "Close Skins", "QS Dropdown", 0, 1, [
              ["KickPunch", 0.5],
              ["SnarePunch", 1],
              ]);

              That’s where I’m getting so confused, I can’t find any objects that could be throwing this error. :/

              DHealey
              In this case it’s because otherwise I get "Can't reference inline function parameters in nested function body” with some other things going on next to it.

              Efficiency is not an issue in this part as it’s all develop only generation of the UI XML, this code won’t ship.

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

                @Fergler said in Can you add line number for error "You must specify the unique component name, not the object itself”?:

                It is an inline function

                I see, you should use local variables within inline functions rather than reg.

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

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

                  @d-healey

                  I edited to fix completely tired misinformation etc in my post but yes I had a bunch of regs left over from misusing them and basically haven’t bothered since this is in module and UI builder code but yes I’ll change them.

                  Taking a 5 month leave from working on this has not been great :D

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

                  23

                  Online

                  1.8k

                  Users

                  12.0k

                  Topics

                  104.7k

                  Posts