addressing indexed component

Discussions of Q-SYS hardware and software.

Moderators: Cameron Shoffner, Christian Cook, Kirk Fyvie, Martin Barbour, Fred Thomke, Gary Evans_QSC, Chris Brouelette

Wed Aug 30, 2017 8:28 am

  • Hi

    may someone help me with addressing a indexed component in a Custom Control...

    Code: Select all
    -- "VideoIn Buttons" is a Custom Control with 32 Trigger Buttons...]
    vt = Component.New("VideoIn Buttons")
    counter = 1

    -- without counter - this works
    -- (but unexpectedly, because Component Lister says the name is trigger.1):
    vt.trigger_1.Legend = "Test"

    -- All these doesn't work:
    vt.trigger[counter].Legend = "Test"
    vt.trigger["counter"].Legend = "Test"
    vt.trigger.counter.Legend = "Test"
    vt.trigger.[counter].Legend = "Test"
    vt.trigger.["counter"].Legend = "Test"
    vt.trigger_counter.Legend = "Test"
    vt.trigger_[counter].Legend = "Test"
    vt.trigger_["counter"].Legend = "Test"
    froggy
    Newbie
     
    Posts: 5
    Joined: Tue Jan 08, 2013 3:43 am

Sun Sep 03, 2017 12:53 am

Wed Sep 06, 2017 1:28 am

  • Code: Select all
    vt.["trigger." .. counter].Legend = "Test"

    says:
    <name> expected near '['

    same with:
    Code: Select all
    vt.["trigger." .. counter].Legend = "Test"


    and
    Code: Select all
    vt.["trigger_" .. counter].Legend = "Test"


    and
    Code: Select all
    vt.["trigger " .. counter].Legend = "Test"


    but thanks anyway...
    froggy
    Newbie
     
    Posts: 5
    Joined: Tue Jan 08, 2013 3:43 am

Thu Sep 07, 2017 8:32 pm

  • Sorry, There was an extra . in that command.

    vt["trigger."..control].Legend is what you need.

    I hadn't fully read what you were trying to do.
    Also see the code below. You can use this to setup event handlers etc on all the controls.

    Code: Select all
    vt = Component.New("VideoIn Buttons")

    for i, v in pairs(vt) do
      triggeridx = tonumber(string.match(i, "[%d]+"))
      vt["trigger."..triggeridx].Legend = "Button "..triggeridx
    end
    Callum Brieske
    Possibly an old pro
     
    Posts: 31
    Joined: Thu May 07, 2015 4:00 am

Thu Sep 07, 2017 8:37 pm

  • I thought Id offer some further clarification on this.

    When you create vt = Componenet.New you are creating a table of controls named vt.
    Therefore to access these controls, you access the table vt with the index being the control name. IE vt["trigger.1"]
    Callum Brieske
    Possibly an old pro
     
    Posts: 31
    Joined: Thu May 07, 2015 4:00 am

Wed Oct 11, 2017 3:57 pm

  • Hi Callum,
    sorry for late answer, was in holiday..
    thanks for your effort, I will try it.

    greetings,
    froggy
    froggy
    Newbie
     
    Posts: 5
    Joined: Tue Jan 08, 2013 3:43 am



Return to Q-SYS Support




Information
  • Users browsing this forum: Bing [Bot], Yahoo [Bot] and 1 guest