HISE Logo Forum
    • Categories
    • Register
    • Login

    Loop Array and Filter by String Prefix.

    Scheduled Pinned Locked Moved Scripting
    17 Posts 3 Posters 134 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.
    • ChazroxC
      Chazrox
      last edited by

      Can somebody help me figure out how to write a proper loop for this? My brain is so done rn. I need to create an array from all samplemaps, but grab only the ones with a specific prefix, i.e.
      "KICKS_Kick 1", "KICKS_Kick 2" and populate them to a "KICKS" combobox.

      I've tried for 3 hours. I want to jab my computer screen. lol.

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

        @Chazrox https://forum.hise.audio/topic/1677/filter-display-samplemap-names-by-prefix?=1741826112149

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

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

          @d-healey tbh that just confused me more. Theres too much going on in there.
          I dont what im even looking at. I guess I have a bunch of studying to do. If thats what it takes to get what I need im probably not gonna get it any time soon. I thought it was a simple 1 liner added to whats usually needed to populate a combobox.

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

            @Chazrox said in Loop Array and Filter by String Prefix.:

            I thought it was a simple 1 liner added to whats usually needed to populate a combobox.

            It's more complicated than that, but not too complicated.

            Start simple. Loop over your array and console print each entry.

            When you can do that, use substring and indexOf to print just the prefix.

            When you can do that, try organising the entries into arrays based on their prefix.

            Just go one step at a time until you know what you're doing. Everything is hard until it's easy.

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

            ChazroxC 2 Replies Last reply Reply Quote 0
            • ChazroxC
              Chazrox @d.healey
              last edited by Chazrox

              @d-healey ok. Im not a quitter lol I'll be back. Thanks for the guidance!

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

                @d-healey im stuck here because everything I try to print prints out to the console 3 times....

                Screenshot 2025-03-12 at 8.26.47 PM.png

                Screenshot 2025-03-12 at 8.27.44 PM.png

                ChazroxC 1 Reply Last reply Reply Quote 0
                • ChazroxC
                  Chazrox @Chazrox
                  last edited by

                  and this thing...

                  startOffset, stypeStrictness. I dont know what that is and I dont see it in the documentation so where do I even learn about this by myself? Please help me.

                  Screenshot 2025-03-12 at 8.38.28 PM.png

                  ChazroxC 1 Reply Last reply Reply Quote 0
                  • ChazroxC
                    Chazrox @Chazrox
                    last edited by

                    Im really trying to learn on my own but most of this stuff comes from you guys.

                    I learned ".length" from you guys but thats not even in the api's lol.

                    Where does that come from and what else is there where that comes from? lol

                    rglidesR 1 Reply Last reply Reply Quote 0
                    • rglidesR
                      rglides @Chazrox
                      last edited by

                      @Chazrox do you just mean content.getAllComponents("KICK");

                      this would get any component starting with KICK, best if you have names like KICK0, KICK1, KICK2 etc

                      and you can do an array like const var kicks = [KICK0, KICK1, KICK2, KICK3];

                      But maybe this isn't what you meant?

                      rglidesR 1 Reply Last reply Reply Quote 0
                      • rglidesR
                        rglides @rglides
                        last edited by

                        @rglides ah yeah me again not fully reading questions :D this doesn't directly help the combobox issue

                        ChazroxC 1 Reply Last reply Reply Quote 0
                        • ChazroxC
                          Chazrox @rglides
                          last edited by

                          @rglides haha all good brotha. Thank you! Im over here wrecking my brain. I've been at this one thing for 11 hours now. You know I thought I was smart until I came here hahahaha Bless! I love a good challenge but some things just need help and const var things = ME; //lol

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

                            @Chazrox Start here https://docs.hise.dev/scripting/scripting-in-hise/javascript.html

                            @Chazrox said in Loop Array and Filter by String Prefix.:

                            startOffset, stypeStrictness. I dont know what that is and I dont see it in the documentation

                            You want String.indexOf rather than Array.indexOf - https://www.w3schools.com/jsref/jsref_indexof.asp

                            HISE Script is based on JavaScript so when it comes to basic functions you can often find the info you need by looking up the JavaScript equivalent.

                            My scripting 101 video might also be useful for you if you haven't seen it already.

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

                            ChazroxC 1 Reply Last reply Reply Quote 1
                            • rglidesR
                              rglides @Chazrox
                              last edited by

                              @Chazrox haha I know the feeling!

                              this should work

                              HiseSnippet 1771.3oc0XssaabCDcWauo1pwAIA4g1GZAgPQfDbriTtVTamHKY4.AeQpVxFAvMHfdWJIVuhbwtT9RCLP+E5uQepeB8SJ+AsC2qb0kDEUG2V8jFxY3blyPxY31vkaR773tZ5Kz5BGhl9MMZdASzsRWLkoUaSM86afwUpua45kq+5xGzpU88ZVdiJauW0W2p9AsZbPqpGVcuVZkuvA64Qrzz0m8URa0WXNM+eu+kkw1XlIIYHMsC4TSxNzdTQxnMJsM01dKrEoEsmh1OoTMSNqB2l2Gv4rFEzbvlmf6P1CKUaFCM8aT0hJ3tMEXAwSSetxbqKZ1keFKP+CodzisIRghZMgEJX3s31VRDKGUqRWpsUiH9vSSS2nQB6La.6bOicoVz3wSXoa6OAJwBU9Pelzva1TvqnJ7Jn.uQ.IcEHMW.jtiQSSWpiHYFId9RiZLAwsMFncUnDnq1L+17FU3fFLwJ8vmP1xEDhsH2iKT3AnmVnP9UyjAndOA5TrKpBu2w7x7yKhVGEYbGh.F1gy.gbYi0Ha9UWTwxxP9ZrFImb.82ibtXr5Kmb.8ah64XSbAS727JMHbnbYC+S.jF1ncwN6P8jdKTwDiCmJW9UQKlwkzIwhsn1.UQr.qN5MqNvj0XVjyIdAygj9rM2EkiBCTXUDEsVZOuhMg0QzElYokxuXl2sXFD7i1FkKkZGQeyJ.1EvFNubY2tVksa91soRlKOB8vGt7xKiNi6dhGR5rdXGOjG9T.gXOThxPVMQnnpviPDgYfqCQf72PA7JN885NDv7IngrIjGBLgFqykKl4RIojJBiW+.x.8BTg7nX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kBVqFXH5UzrLsSreBFQ86QDy39nR4aYLhuJvM9b8gJlaxN28g+NJ+O3lzTeWkEhvXSpL6TkcJbBEFQhw6B0uai6aKhFM8sE6xYbmtbF0L84AX+cmNDWUrOx.ZCgPVXMdj6UZen4OrmxA5uqzNPCkX2zGy+j3hhexeioQlu9Ji.3hjWwg9mj2tV2l8AqFN6DUM7JGuSekwqUp6Vg0HQf2cE+GOOeSC+a0Qxhv+aA0848EPw0nBbFPUvlPkeShZsPYe2gxEjxR.0jvr7E9K3W3jEiJbJmrXzjZlQKEDag+2+0H5yRXxRG9M4YCkjsU2R6A8WHgDTr6ZAk8vlt72ZF7VKIVm2eD.kL+Oh+BF6JkQIOuJFp8f5Uu0zL8RMjgOZZM7wSqgOYZM7oSqgOaZM74Sqge+G2PY6DazWv6EbYpl1tMpFrATuZ7FvY09aCKtTjB
                              
                              ChazroxC 1 Reply Last reply Reply Quote 0
                              • ChazroxC
                                Chazrox @d.healey
                                last edited by

                                @d-healey Thanks. I'm still sitting here trying. I've watched that video like 4 times in full and taken extensive notes but its just gonna take repetition to retain everything. It is alot. Loops are next level for me. I've figured out alot considering I have zero coding background and I've managed to finish a few plugins in my first month. This is considered advanced for me at the moment but i'll get it. I appreciate the help always! Im never asking for handouts!

                                Screenshot 2025-03-12 at 9.37.24 PM.png

                                see...there's ".length" in my OWN notes but I forgot I even wrote that. lol

                                1 Reply Last reply Reply Quote 0
                                • ChazroxC
                                  Chazrox @rglides
                                  last edited by

                                  @rglides part of me doesn't want to open this.....but I have to. LOL Im just trying to understand the logic. Thank You!

                                  rglidesR 1 Reply Last reply Reply Quote 0
                                  • rglidesR
                                    rglides @Chazrox
                                    last edited by

                                    @Chazrox ha yeah it is really important to really learn it all, but snippets can help to learn, they can also soothe a headache sometimes lol

                                    ChazroxC 1 Reply Last reply Reply Quote 1
                                    • ChazroxC
                                      Chazrox @rglides
                                      last edited by

                                      @rglides 100% ! 🙏

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

                                      51

                                      Online

                                      1.7k

                                      Users

                                      11.7k

                                      Topics

                                      101.8k

                                      Posts