Get Item In List


Node Information
Gets Item in the list at the specified index.Click the info button to specify the type, then attach the list to 'List', then specify the index of the item you want to get.
General Information
• This node doesn't have other available options.
• Some of the ports of this node can change their types and accept types automatically.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
List IN List<Object> ONE TRUE TRUE
Index IN Int32 ONE FALSE FALSE
Value OUT Object MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.List
{
    [IsNode("Get Item In List")]
    public class ListGetItem : Node
    {
        Port list = new Port(PortType.IN, typeof(List<object>), AcceptsLinks.ONE, "List");
        Port itemnum = new Port(PortType.IN, typeof(int), AcceptsLinks.ONE, "Index");
        Port get = new Port(PortType.OUT, typeof(object), AcceptsLinks.MULTIPLE, "Value");
        public ListGetItem()
        {
            this.Name = "Get Item In List";
            AddPort(list);
            AddPort(itemnum);
            AddPort(get);
            list.CustomAcception = Accepts;
            get.Instructions = "init";
            Information = "Gets Item in the list at the specified index." +
                "Click the info button to specify the type, then attach the list to 'List', " +
                "then specify the index of the item you want to get.";
        }
        private bool Accepts(Port port)
        {
            if (port == null)
            {
                return false;
            }
            if (list.IsConnected)
            {
                return false;
            }
            if (port.DataType != null && port.IsList)
            {
                list.DataType = port.DataType;
                get.DataType = GraphCore.GetListSubType(port.DataType);
                return true;
            }
            return false;
        }
        public override void UpdateResults()
        {
            if (get.ConnectedPorts.Count == 0 || list.ConnectedPorts.Count == 0)
            {
                IsInfoMenuEnabled = true;
            }
            else
            {
                IsInfoMenuEnabled = false;
            }
            if (list.ConnectedPorts.Count < 1)="" {="" status="NodeStatus.ERROR;" errormessage="No arrays attached." ;="" }="" else="" {="" status="NodeStatus.OK;" errormessage="string.Empty;" }="" get.instructions="GetValue(list)" +="" "["="" +="" getvalue(itemnum)="" +="" "]";="" }="" }="" }=""></object>