HISE Logo Forum
    • Categories
    • Register
    • Login

    get Index from 2 arrays simultaneously?

    Scheduled Pinned Locked Moved Scripting
    50 Posts 3 Posters 2.3k 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.
    • ten7kurT
      ten7kur @ten7kur
      last edited by

      @ten7kur said in get Index from 2 arrays simultaneously?:

      Like i said, i need help, im at loss what to do..
      Tried so many things..

      If you could point the right direction id really appreciate it!!

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

        Could you reword the question because I'm still not clear what you're trying to do. The thread title is get Index from 2 arrays simultaneously? but then your post is talking about viewports.

        ten7kurT 1 Reply Last reply Reply Quote 0
        • ten7kurT
          ten7kur @d.healey
          last edited by

          @d-healey said in get Index from 2 arrays simultaneously?:

          Could you reword the question because I'm still not clear what you're trying to do. The thread title is get Index from 2 arrays simultaneously? but then your post is talking about viewports.

          The last part of the script: @line49

          inline function onViewport2Control(component, value)
          {
          

          Im trying to get 2 variables to say = yes
          (inside the inline_function)
          I cant get it to work

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

            This post is deleted!
            ten7kurT 1 Reply Last reply Reply Quote 0
            • ten7kurT
              ten7kur @d.healey
              last edited by ten7kur

              @d-healey said in get Index from 2 arrays simultaneously?:

              Maps doesn't exist inside this function.

              thats what i thought.
              How can i get at it?

              EDIT: precisely , how can i access a variable outside the inline function?

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

                @ten7kur You commented faster than I could delete my post :p

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

                  I think this is where the problem is.

                  var Item1 = ["Item1A","Item1B","Item1C"];
                  var Item2 = ["Item2A","Item2B"];
                  
                  var Maps = [Item1, Item2];
                  

                  This is what maps contains

                  [
                    [
                      "Item1A",
                      "Item1B",
                      "Item1C"
                    ],
                    [
                      "Item2A",
                      "Item2B"
                    ]
                  ]
                  

                  Is that what you want?

                  1 Reply Last reply Reply Quote 0
                  • ten7kurT
                    ten7kur
                    last edited by ten7kur

                    hmm
                    Im trying to get the index of both arrays.
                    The INDEX of var Item1 and then the INDEX of Item1A, Item1b, Item1C.

                    So if var Item1 is true AND var Item1A is true, i can do something.

                    LindonL 1 Reply Last reply Reply Quote 0
                    • LindonL
                      Lindon @ten7kur
                      last edited by Lindon

                      @ten7kur getting an INDEX of an item in an array? will return you a position in the array - not a true/false answer (well apart from the first two ..)

                      your code says;

                      if (Maps[value] == 0 && value == 0)

                      where Maps[value] will always = another array , not zero...

                      HISE Development for hire.
                      www.channelrobot.com

                      ten7kurT 1 Reply Last reply Reply Quote 0
                      • ten7kurT
                        ten7kur @Lindon
                        last edited by

                        @Lindon said in get Index from 2 arrays simultaneously?:

                        @ten7kur getting an INDEX of an item in an array? will return you a position in the array - not a true/false answer (well apart from the first two ..)

                        your code says;

                        if (Maps[value] == 0 && value == 0)

                        where Maps[value] will = another array , not zero...

                        Buts thats what i want, is the Position in the array. Then i can do a true/false if. Dont i? Ive tried everyting(as in my first post described)
                        All credit to @lindon , thats where this code comes from

                        LindonL 1 Reply Last reply Reply Quote 0
                        • LindonL
                          Lindon @ten7kur
                          last edited by

                          @ten7kur OK look this code:

                          inline function onViewport2Control(component, value)
                          {
                          	SelectedItemName.set("text",Maps[Viewport1.getValue()][value]);
                          	
                          	//print selection Index
                          	Console.print("selected:" + value);
                          	
                          	// if both Indexs are correct, then print "OK-selected"
                          	if (Maps[value] == 0 && value == 0) {
                          	    local Selection = "OK-selected";
                          	    Console.print("selecton:" + Selection);
                          	}	
                          };
                          Content.getComponent("Viewport2").setControlCallback(onViewport2Control);
                          

                          Just put this line in there:

                          Console.print(Maps[value]);
                          

                          and you will see you are getting an array back.... not a value.
                          So this:

                          if (Maps[value] == 0)
                          

                          will NEVER be true...

                          What are you trying to do?

                          HISE Development for hire.
                          www.channelrobot.com

                          ten7kurT 2 Replies Last reply Reply Quote 0
                          • ten7kurT
                            ten7kur
                            last edited by

                            I dont know how much easier i can explain.
                            I wish to do:
                            If the index of Vieport1 and index of Viewport2 = to what i want, then do........somethng ,eg print console

                            1 Reply Last reply Reply Quote 0
                            • ten7kurT
                              ten7kur @Lindon
                              last edited by

                              @Lindon said in get Index from 2 arrays simultaneously?:

                              @ten7kur OK look this code:

                              inline function onViewport2Control(component, value)
                              {
                              	SelectedItemName.set("text",Maps[Viewport1.getValue()][value]);
                              	
                              	//print selection Index
                              	Console.print("selected:" + value);
                              	
                              	// if both Indexs are correct, then print "OK-selected"
                              	if (Maps[value] == 0 && value == 0) {
                              	    local Selection = "OK-selected";
                              	    Console.print("selecton:" + Selection);
                              	}	
                              };
                              Content.getComponent("Viewport2").setControlCallback(onViewport2Control);
                              

                              Just put this line in there:

                              Console.print(Maps[value]);
                              

                              and you will see you are getting an array back.... not a value.
                              So this:

                              if (Maps[value] == 0)
                              

                              will NEVER be true...

                              What are you trying to do?

                              Yes that works, but i need 2 variables to = True

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

                                @ten7kur WHICH TWO VARIABLES!!!

                                HISE Development for hire.
                                www.channelrobot.com

                                1 Reply Last reply Reply Quote 1
                                • ten7kurT
                                  ten7kur @Lindon
                                  last edited by

                                  @Lindon said in [get Index from 2 arrays simultaneously?]

                                  What are you trying to do?

                                  trying to pass another variable if both = to True

                                  LindonL 1 Reply Last reply Reply Quote 0
                                  • LindonL
                                    Lindon @ten7kur
                                    last edited by Lindon

                                    @ten7kur both what are equal true? There is NO "True" inside the array

                                    there is no way that Maps[any value here] will EVER = true.

                                    it can only ever = the contents of one of the array slots or undefined.

                                    HISE Development for hire.
                                    www.channelrobot.com

                                    ten7kurT 1 Reply Last reply Reply Quote 0
                                    • ten7kurT
                                      ten7kur
                                      last edited by

                                      @Lindon said in get Index from 2 arrays simultaneously?:

                                      WO VARIABLES!!!

                                      So thats my question.
                                      I need to have a True to both items.
                                      var Maps. and the Viewport2 value

                                      uhh this is heavy

                                      LindonL 1 Reply Last reply Reply Quote 0
                                      • ten7kurT
                                        ten7kur @Lindon
                                        last edited by

                                        @Lindon said in get Index from 2 arrays simultaneously?:

                                        @ten7kur both what are equal true? There is NO "True" inside the array

                                        there is no way that Maps[any value here] will EVER = true.

                                        it can only ever = the contents of one of the array slots or undefined.

                                        Then to "Item1"?
                                        This cant be impossible

                                        LindonL 1 Reply Last reply Reply Quote 0
                                        • LindonL
                                          Lindon @ten7kur
                                          last edited by

                                          @ten7kur You have MAPS set up as David has explained:

                                          [
                                            [
                                              "Item1A",
                                              "Item1B",
                                              "Item1C"
                                            ],
                                            [
                                              "Item2A",
                                              "Item2B"
                                            ]
                                          ]
                                          

                                          so there are two only slots in Maps

                                          Maps[0] = ["Item1A", "Item1B","Item1C" ]

                                          Maps[1] = ["Item2A","Item2B"]

                                          So any number you put in Maps[xxxx] will NEVER = true

                                          HISE Development for hire.
                                          www.channelrobot.com

                                          ten7kurT 1 Reply Last reply Reply Quote 0
                                          • LindonL
                                            Lindon @ten7kur
                                            last edited by Lindon

                                            @ten7kur said in get Index from 2 arrays simultaneously?:

                                            @Lindon said in get Index from 2 arrays simultaneously?:

                                            @ten7kur both what are equal true? There is NO "True" inside the array

                                            there is no way that Maps[any value here] will EVER = true.

                                            it can only ever = the contents of one of the array slots or undefined.

                                            Then to "Item1"?
                                            This cant be impossible

                                            You dont have anything called "Item1" -- anywhere...

                                            you've got Maps[0][0] = "Item1A"
                                            you've got Maps[1][0] = "Item2A"

                                            Can you just say in english what you are trying to do...e.g. "make sure Viewport1 and Viewport2 are the same"... or something else?

                                            HISE Development for hire.
                                            www.channelrobot.com

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

                                            20

                                            Online

                                            1.7k

                                            Users

                                            11.8k

                                            Topics

                                            102.5k

                                            Posts