Loop through objects
Table of Contents


Pinnacle scripting does not allow typical programming loops, however, it is possible to loop over an object. Each object is passed to a script.

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


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).

//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). 

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


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


//-----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;


      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";

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License