List/Array Variables


A list is a one or two-dimensional array of variables of float or string type (the terms "List" and "Array" may be used interchangeably). They are very commonly used by Pinnacle (e.g. ROIlist, TrialList, PrescriptionList), but can also be user-generated.

User-generated Lists/Arrays

  • Lists may consist of String or Float variables
  • In Pinnacle versions prior to 9.0, it may have been possible to use 2D arrays. That no longer seems to be an option in more modern releases.
  • Float Lists can utilize mathematical arguments
  • List items are accessed by index number and can be edited or deleted after creation
  • User-generated Lists can be utilized for looping

Create String and Float Lists

List of string varables [1]

  • Can use ".Name" or ".Value" when referencing the item. The refer to the same value.
Store .At .ArrayName = ObjectList{ChildClassName = "SimpleString";};
Store .At .ArrayName .CreateChild = "";
Store .At .ArrayName .Last .Value = "1";  //Quotes "" are not necessary for numbers.

Store .At .ArrayName .CreateChild = "";
Store .At .ArrayName .Last .Value = "This is a string";

Store .At .ArrayName .CreateChild = "";
Store .At .ArrayName .Last .Name = "3"; //".Name" and ".Value" are interchangeable in String arrays (but not float array).

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

List of float variables

  • Float Lists can only use the ".Value" identifier. Unlike String Lists, Pinnacle will give an error if ".Name" is utilized.
Store.At.ArrayName = ObjectList{ChildClassName="Float";};
Store.At.ArrayName.CreateChild = "";

Store.At.ArrayName.CreateChild = "";

InfoMessage = Store.At.ArrayName.#"#0".Value;

List Actions

  • These work on String and Float Arrays

Change values (assuming list has already been created)

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

Delete list/array item

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

Check if a list contains items (HasElements/HasNoElements)

  • If a script loops over an user-generated list with no elements it will likely crash.
  • Use with an IF statements
  • HasElements will detect an element if an object/item has been created (i.e. .CreateChild="" has been used). It does not require that the object be assigned a value.
//InfoMessage will appear if ArrayName contains any item/elements
IF.Store.At.ArrayName.HasElements.THEN.InfoMessage = "Elements exist";//Outputs "Elements exist"

//InfoMessage will appear if ArrayName does not contain any items/elements
IF.Store.At.ArrayName.HasNoElements.THEN.InfoMessage = "No Elements";//Does nothing because a list element exists.

Loop through list

//ArrayName is a list/array of floats
//Set each item in contour list to a value of 1.

Store .At .ArrayName .ChildrenEachCurrent.#"@".Store .At. ContourList .Current .Value=1;

Mathematical Operations (Float variables only)

//A list with at least the first the two items containing numerical values
Store.At.ArrayName.#"#0".Add = Store.At.ArrayName.#"#1".Value;  //Add array items 0 and 1
Store.At.ArrayName.#"#0".Subtract = Store.At.ArrayName.#"#1".Value; //Subtract array items 0 and 1
Store.At.ArrayName.#"#0".Divide = Store.At.ArrayName.#"#1".Value; //Divide array items 0 and 1
Store.At.ArrayName.#"#0".Multiply = Store.At.ArrayName.#"#1".Value; //Muliply array items 0 and 1

Store.At.ArrayName.#"#0".Add =7; //Another option is to use hard-coded values or float variables

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