List/Array Variables

Description

A list is a one or two-dimensional array of objects of float or string type. They are very commonly used by Pinnacle (e.g. ROIlist, TrialList, PrescriptionList), but can also be user-defined.

Examples

1D List

Create the List [1]

Store .At .number = ObjectList{ChildClassName = "SimpleString";};
Store .At .number .CreateChild = "";
Store .At .number .Last .Value = "1"; //.Name also works in place of .Value.  Quotes "" aren't necessary for numbers.

Store .At .number .CreateChild = "";
Store .At .number .Last .Value = "2";

Store .At .number .CreateChild = "";
Store .At .number .Last .Value = "3";

InfoMessage = Store.At.number.#"#2".Value; //Outputs 3

Change values (assuming list has already been created)

Store.At.number.#"#1".Value=7;//Changes index 1 (2nd list object) to 7. Index range starts with 0.

Delete list item

Store.At.number.#"#1".Destroy=""; //Delete the list item in index 1 (2nd list object).

Loop through list

//ContourList is a list/array of floats
//Set each item in contour list to a value of 1.
Store.At.ContourList.ChildrenEachCurrent.#"@".Store.At.ContourList.Current.Value=1;

Old Methods

These may not work in versions >9.8.

1D List [2]

Store.At.test = CreateInstanceOf.ObjectList;
Store.At.test.Add = CreateInstanceOf.SimpleString;
Store.At.test.Add = CreateInstanceOf.SimpleString;
Store.At.test.#"#0".Value = "a";
Store.At.test.#"#1".Value = "b";
Echo = Store.At.test.#"#0".Value;
Echo = Store.At.test.#"#1".Value;
Echo = Store.At.test.Count;
Store.FreeAt.test = "";

2D List [2]

Store.At.test = CreateInstanceOf.ObjectList;
Store.At.test.Add = CreateInstanceOf.ObjectList;
Store.At.test.Last.Add = CreateInstanceOf.SimpleString;
Store.At.test.Last.Last.Value = "a";
Store.At.test.Last.Add = CreateInstanceOf.SimpleString;
Store.At.test.Last.Last.Value = "b";
Echo = Store.At.test.Last.First.Value;
Echo = Store.At.test.Last.Last.Value;
Echo = Store.At.test.Count;
Echo = Store.At.test.First.Count;
Store.FreeAt.test = "";
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License