Appending Number to Modulator Name

Home Forums General Programming Appending Number to Modulator Name

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #118689
    spiffo
    Participant
      • Topics: 12
      • Replies: 38
      • Total: 50

      Ok, so I have 256 Modulators named sequentially:

      Prog_Ch_Table_1
      Prog_Ch_Table_2 …etc

      I’m trying to get all their values in a loop like this:

      for i = 1, 256 do
      local Prog_Change_SysEx = panel:getModulatorByName(“Prog_Ch_Table_”..i):getModulatorValue()
      end

      But it’s giving me the ‘attempt to index a nil value’ error

      I also tried forming a String instead, like this:

      for i = 1, 256 do
      local Prog_Change_String = string.format(“Prog_Ch_Table_%1d”, i)
      local Prog_Change_SysEx = panel:getModulatorByName(Prog_Change_String):getModulatorValue()
      end

      But that gives me ‘attempt to index a nil value’ as well!

      So what is the correct way to get the 256 Modulator Values in a loop?

      As always your help is gratefully received!

      #118690
      spiffo
      Participant
        • Topics: 12
        • Replies: 38
        • Total: 50

        Ooops, my bad. I forgot I haven’t finished creating all 256 Modulators yet!

        Actually both methods work fine, for the record 🙂

        #118691
        human fly
        Participant
          • Topics: 124
          • Replies: 1070
          • Total: 1194
          • ★★★★

          (oh dear i’m very rusty, need to get back into it) this was to collect button states into a table (used for other stuff afterwards). initialise a table first (here it’s local/temporary). here i was collecting a component property, but it’s the same thing with a modulator value. and then use table.insert. then you can make a string from your table.

          function kgetcolour()	
          local tbl_kitcolour={}
          for i=1,5 do 
          	local kitcolour=panel:getComponent("keydata"..i-):getProperty("uiButtonTextColourOff")
          	table.insert(tbl_kitcolour,kitcolour)
          end

          edit: ah couldn’t seen the parentheses in your post!

          • This reply was modified 3 years, 10 months ago by human fly.
        Viewing 3 posts - 1 through 3 (of 3 total)
        • The forum ‘Programming’ is closed to new topics and replies.
        There is currently 0 users and 66 guests online
        No users are currently active
        Forum Statistics
        Threads: 2,495, Posts: 17,374, Members: 77,605
        Most users ever online was 12 on January 22, 2019 3:47 pm
        Ctrlr