HISE Logo Forum
    • Categories
    • Register
    • Login

    Is there a method to search inside an object similar to methods for an array?

    Scheduled Pinned Locked Moved Scripting
    2 Posts 2 Posters 59 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.
    • VirtualVirginV
      VirtualVirgin
      last edited by

      Things like .indexOf() or .contains()
      How can I find out if an object contains an element?

      You can listen to my orchestral mockups here:
      https://www.virtualvirgin.net/

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

        @VirtualVirgin Good old fashioned loop.

        inline function objectContains(key)
        {
            local result = false;
        
            for (x in obj)
            {
                if (isDefined(x[key]))
                    return true;
            }
        
            return result;
        }
        
        

        If you're just looking at the top level of the object then simply isDefined(obj[key])

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

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

        17

        Online

        1.8k

        Users

        12.1k

        Topics

        104.9k

        Posts