HISE Logo Forum
    • Categories
    • Register
    • Login

    Store object in a panel's value object with undefined sub objects...

    Scheduled Pinned Locked Moved General Questions
    4 Posts 2 Posters 40 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.
    • ustkU
      ustk
      last edited by ustk

      @Christoph-Hart Yeah so this was driving me nuts for hours. And now I've found what it was I reckon it happened to me already in the past...

      SoI have an object that is containing some undefined values, like:

      reg myArray = [{obj:"blabla", area:undefined}];
      

      You can apparently store it successfully in a panel value as I see it in the xml afterward. But at recall time, the object won't load because its type will be number instead of object (failing the check of 1st initialisation)

      reg myArray = [{obj:"blabla", area:undefined}];
      
      inline function onPanelControl(component, value)
      {
      	if (typeof(value) != "object")
      		component.setValue(myArray);
      	else
      		Console.print(trace(component.getValue())); // never arrives here...
      };
      Panel.setControlCallback(onPanelControl);
      

      So the issue is that undefined isn't parsed and of course I can fix that with whatever value, [] or "" instead.

      <Control type="ScriptPanel" id="mbPnl" value="JSON[{&quot;obj&quot;: &quot;blabla&quot;, &quot;area&quot;: undefined, ... // Not parsed
      

      undefined is very useful when scripting, so it it possible to make it parsable?

      Hise made me an F5 dude, browser just suffers...

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

        @Christoph-Hart Actually it's even worse... area later becomes a Rectangle object, that of course won't recall... I have to let go the Rectangle option for the project and stick with the ol' array...

        Hise made me an F5 dude, browser just suffers...

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

          @ustk you can always convert back and to an rectangle from an array, but yeah for storing / restoring things you need to resort to vanilla Javascript data types.

          ustkU 1 Reply Last reply Reply Quote 1
          • ustkU
            ustk @Christoph Hart
            last edited by

            @Christoph-Hart Yeah in the end it wasn't hard to just jump between Rectangles and arrays

            area = Rectangle(fromArray).modify().toArray();
            

            Hise made me an F5 dude, browser just suffers...

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

            32

            Online

            1.9k

            Users

            12.3k

            Topics

            107.3k

            Posts