Loop through objects

Description

Pinnacle scripting does not allow typical programming loops, however, it is possible to loop through a list of objects. These lists can be generic Pinnacle lists like TrialList, BeamList and ROIList or user created lists/arrays.

ChildrenEachCurrent.#"@". is the basic command used to execute the loop.

Examples

Set each prescription in a trial to "Current" and then call the specified script.

TrialList.Current.PrescriptionList.ChildrenEachCurrent.#"@".Script.ExecuteNow = Store.StringAt.ScriptLocation;

Change a parameter (The linac used by the active beam in this example).

TrialList.ChildrenEachCurrent.#"@".TrialList.Current.BeamList.Current.Machine="SomeMachineName";
//Not a great example because only the first beam in a trial will have the machine changed,
//but could be used to change something else specifically trial-related.

Loop through a user generated array

//ContourList is a 1-D array of float variables generated by a script (see the "List (Array) variables" page). 
Store.At.ContourList.ChildrenEachCurrent.#"@".Store.At.ContourList.Current.Value=1;

Create an IF-THEN test and then execute that test on multiple objects by utiliziing a loop.

//This command will output a message if PTV is present in RoiList.
Store.StringAt.str = "PTV";
Store.StringAt.tst = "IF.RoiList.Current.Name.STRINGEQUALTO.Store.StringAt.str.THEN.InfoMessage = message"; //***Quotes around the "message" are not necessary
RoiList.ChildrenEachCurrent.#"@".Store.At.tst.Execute = "";

Compute all beams in every trial

TrialList.ChildrenEachCurrent.#"@".ComputeUncomputedBeams="";

Loop in a Menu (when a button or checkbox is selected, with an IF-THEN)

Store.FloatAt.SelectAll=0;

//-----Select All checkbox

Store .At .TempWindow .AddChild = "";
Store .At .TempWindow .WidgetList.Last = {
      WidgetClass = "ToggleButton";
      ParentName = "ScrollRegion";
      Name = "SelectAllCheckboxes";
      X = 5;
      Y = 35;
      Width = 20;
      Height = 20;

      QueryValueKey="Store.FloatAt.SelectAll";

      AddAction = "";
      ReplaceCurrentAction = "Store.FloatAt.SelectAll";//Replace ContourList value with QueryValue (0 or 1)
      AddAction = "";
      ReplaceCurrentAction = "IF.Store.FloatAt.SelectAll.EQUALTO.#1.THEN.Store.At.ContourList.ChildrenEachCurrent.@.Store.At.ContourList.Current.Value=1";
      AddAction = "";
      ReplaceCurrentAction = "IF.Store.FloatAt.SelectAll.EQUALTO.#0.THEN.Store.At.ContourList.ChildrenEachCurrent.@.Store.At.ContourList.Current.Value=0";

      ResetDependenciesWhenRealized=1;
};
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License