Component
Component objects allow access to Named Components in the design. Create a Named Component by typing a unique, non-default name in any component block.
Create a Named Component reference in your script.
Syntax
Component.New("named_component")
Example
In this example, we have two Named Components in a design, "gain a" and "gain b". We are watching the gain of "gain a" and muting "gain b" if "gain a" goes above 0 dB.
gainA = Component.New("gain a")
gainB = Component.New("gain b")
gainA.gain.EventHandler = function( ctl )
if gainA.gain.Value > 0 then
gainB.mute.Boolean = true
else
gainB.mute.Boolean = false
end
end
Returns a table of all controls in the specified Named Component.
Note: You can also use Tools > View Component Controls Info to see a list of all controls for a selected component, including a named component. See Viewing Component Control Information.
Syntax
Component.GetControls("named_component")
Examples
In this example, we have a Blinking LED component named "led". We want to obtain a list of all its controls and their properties.
blinker = Component.New("led")
b_ctrls = Component.GetControls(blinker)
print("Component GetControls: ")
for _,b_element in ipairs(b_ctrls) do
print("Name: "..tostring(b_element.Name))
print(".\tValue: "..tostring(b_element.Value))
print(".\tString: "..tostring(b_element.String))
print(".\tPosition: "..tostring(b_element.Position))
print(".\tType: "..tostring(b_element.Type))
print(".\tDirection: "..tostring(b_element.Direction))
print(".\tMinValue: "..tostring(b_element.MinValue))
print(".\tMaxValue: "..tostring(b_element.MaxValue))
print(".\tMinString: "..tostring(b_element.MinString))
print(".\tMaxString: "..tostring(b_element.MaxString))
end
Note: b_element.Boolean, RampTime, and Index are omitted from the request since they do not apply in this context.
Debug Output
2019-10-28T18:48:10.938Starting Script 2019-10-28T18:48:10.938Component GetControls: 2019-10-28T18:48:10.938Name: blink 2019-10-28T18:48:10.939. Value: true 2019-10-28T18:48:10.939. String: true 2019-10-28T18:48:10.939. Position: 1.0 2019-10-28T18:48:10.939. Type: Boolean 2019-10-28T18:48:10.939. Direction: Read Only 2019-10-28T18:48:10.939. MinValue: 0.0 2019-10-28T18:48:10.939. MaxValue: 1.0 2019-10-28T18:48:10.939. MinString: false 2019-10-28T18:48:10.939. MaxString: true 2019-10-28T18:48:10.939Name: duty.cycle 2019-10-28T18:48:10.939. Value: 50.0 2019-10-28T18:48:10.939. String: 50.0% 2019-10-28T18:48:10.939. Position: 0.5 2019-10-28T18:48:10.939. Type: Float 2019-10-28T18:48:10.939. Direction: Read/Write 2019-10-28T18:48:10.939. MinValue: 10.0 2019-10-28T18:48:10.939. MaxValue: 90.0 2019-10-28T18:48:10.939. MinString: 10.0% 2019-10-28T18:48:10.939. MaxString: 90.0% 2019-10-28T18:48:10.939Name: enable 2019-10-28T18:48:10.939. Value: true 2019-10-28T18:48:10.939. String: enabled 2019-10-28T18:48:10.939. Position: 1.0 2019-10-28T18:48:10.939. Type: Boolean 2019-10-28T18:48:10.939. Direction: Read/Write 2019-10-28T18:48:10.939. MinValue: 0.0 2019-10-28T18:48:10.939. MaxValue: 1.0 2019-10-28T18:48:10.939. MinString: disabled 2019-10-28T18:48:10.939. MaxString: enabled 2019-10-28T18:48:10.939Name: random 2019-10-28T18:48:10.939. Value: false 2019-10-28T18:48:10.939. String: disabled 2019-10-28T18:48:10.939. Position: 0.0 2019-10-28T18:48:10.939. Type: Boolean 2019-10-28T18:48:10.939. Direction: Read/Write 2019-10-28T18:48:10.939. MinValue: 0.0 2019-10-28T18:48:10.939. MaxValue: 1.0 2019-10-28T18:48:10.939. MinString: disabled 2019-10-28T18:48:10.939. MaxString: enabled 2019-10-28T18:48:10.939Name: time 2019-10-28T18:48:10.939. Value: 10.0 2019-10-28T18:48:10.939. String: 10.0s 2019-10-28T18:48:10.939. Position: 1.0 2019-10-28T18:48:10.939. Type: Float 2019-10-28T18:48:10.939. Direction: Read/Write 2019-10-28T18:48:10.939. MinValue: 0.1 2019-10-28T18:48:10.939. MaxValue: 10.0 2019-10-28T18:48:10.939. MinString: 100ms 2019-10-28T18:48:10.939. MaxString: 10.0s
In this example, we know that a Custom Controls component (named "cc") contains a control called time.1. We want to obtain the properties only for that control.
cc = Component.New("cc")
local ctl = cc["time.1"]
cc_ctrls = Component.GetControls(cc)
print("Properties for time.1 :")
print(".\tValue: "..tostring(ctl.Value))
print(".\tString: "..tostring(ctl.String))
print(".\tPosition: "..tostring(ctl.Position))
print(".\tBoolean: "..tostring(ctl.Boolean))
print(".\tRampTime: "..tostring(ctl.RampTime))
print(".\tIndex: "..tostring(ctl.Index))
print(".\tType: "..tostring(ctl.Type))
print(".\tDirection: "..tostring(ctl.Direction))
print(".\tMinValue: "..tostring(ctl.MinValue))
print(".\tMaxValue: "..tostring(ctl.MaxValue))
print(".\tMinString: "..tostring(ctl.MinString))
print(".\tMaxString: "..tostring(ctl.MaxString))
Note: ctl.Name is omitted since it does not apply in this context.
Debug Output
2019-10-28T19:45:52.318Starting Script 2019-10-28T19:45:52.318Properties for time.1 : 2019-10-28T19:45:52.318. Value: 80.200004577637 2019-10-28T19:45:52.318. String: 00:01:20 2019-10-28T19:45:52.318. Position: 0.72000002861023 2019-10-28T19:45:52.318. Boolean: true 2019-10-28T19:45:52.318. RampTime: 0.0 2019-10-28T19:45:52.318. Index: -1 2019-10-28T19:45:52.318. Type: Time 2019-10-28T19:45:52.318. Direction: Read/Write 2019-10-28T19:45:52.318. MinValue: 1.0 2019-10-28T19:45:52.318. MaxValue: 111.0 2019-10-28T19:45:52.318. MinString: 00:00:01 2019-10-28T19:45:52.318. MaxString: 00:01:51
