Pinnacle : IF Statements

Description

The IF-THEN and IF-THEN-Else conditional statements are used to “test” an object and then execute commands based on the result.
  • IF-THEN: If the result is true, then the action will occur. Otherwise, no action will be performed.
  • IF-THEN-ELSE: If the result is true, then the action will occur. Otherwise the “ELSE” action will be performed.

Syntax

IF-THEN

  • One action executed
IF. SomeObjectOrValue. TEST. AnotherObjectOrValue. THEN. DoSomeAction;
  • Multiple actions executed
IF. SomeObjectOrValue. TEST. AnotherObjectOrValue. THEN={
DoAction1;
DoAction2;
DoAction3;
...
};
  • Nested IF
IF. SomeObjectOrValue. TEST. AnotherObjectOrValue. THEN={
    IF.SomeOtherObjectOrValue.TEST.AnotherObjectOrValue1.THEN.DoSomeAction;
...
};

IF-THEN-ELSE

  • These statements can fail due to
      • Multiple equals signs (=) in a statement
      • Quotation marks may also occasionally be an issue
  • An easy way around this is to pre-declare an action as a string and execute it
  • Often at least one of the two actions will need to be declared as a string and then executed
  • The .Execute command can be used to execute a string after THEN
  • If both actions are declared as strings, the ELSE action must end with .Execute="";
IF. SomeObjectOrValue. TEST. AnotherObjectOrValue. THEN. DoSomeAction. ELSE. DoAnotherAction;
Store.StringAt.Action1 = The Other Action;
IF. SomeObjectOrValue. TEST. AnotherObjectOrValue. THEN. Store.At.Action1.Execute .ELSE. DoAnotherAction;
Store.StringAt.Action1 = The First Action;
Store.StringAt.Action2 = The Other Action;
IF. SomeObjectOrValue. TEST. AnotherObjectOrValue. THEN. Store.At.Action1.Execute. ELSE. Store.At.Action2.Execute="";

List-specific tests

ContainsObject

Description

  • ContainsObject checks if an object is present in a list/group.
  • Returns 1 (true) or 0 (false)
  • * The specified name must match the Pinnacle object name perfectly.
    • If RoiList contains “PTV3”, ContainsObject will return “false” if “PTV” is the search term.
  • Quotes and # are only necessary if the object name contains any special characters
    • Cord+5 needs to be written as #"Cord+5"
  • Variables cannot be used to specify an object name.

Examples

IF.RoiList.ContainsObject. PTV. THEN.InfoMessage="Contains the ROI"; //Quotation marks are not necessary if the object does not contain special characters.
IF.RoiList.ContainsObject. #"PTV+3". THEN.InfoMessage="Contains the ROI"; //Quotes and # may be necessary if special characters are present.
  • Variables cannot be used, so this code will not return any value even if PTV is present in RoiList.
//This will not return correct values.
Store.StringAt.tempstr = "PTV";
IF.RoiList.ContainsObject. Store.StringAt.tempstr. THEN.InfoMessage="Contains the ROI";
  • A string can be created and executed, however, to utilize variables.
This example doesn't yet exist, but will create a string with a desired variable name and execute then execute the string.

HasElements/HasNoElements

  • Check if a Pinnacle or user-generated list has any items
IF.BolusList.HasElements.THEN.InfoMessage = "Bolus used"; //Check if BolusList has elements (i.e. is bolus used)
IF.BolusList.HasNoElements.THEN.InfoMessage = "Bolus not used"; //Check if BolusList is empty

IF.TrialList.Current.PrescriptionList.HasElements.THEN.InfoMessage = "Prescriptions exist"; 
IF.TrialList.Current.BeamList.HasNoElements.THEN.InfoMessage ="No beams exist";

Float-specific tests

  • EQUALTO
  • NOTEQUALTO
  • GREATERTHAN
  • LESSTHAN
  • GREATERTHANOREQUALTO
  • LESSTHANOREQUALTO

String-specific tests

  • STRINGEQUALTO
  • STRINGNOTEQUALTO
  • IsNull (This is case sensitive)
  • Is
    • Seems to work for Pinnacle variable existence tests, but not user-created variables.
    • !IsNull should work like “Is” user for user-created variables (sometimes?!)
  • Contains (case sensitive)

Boolean-specific tests

  • AND
  • OR
  • XOR

Special values

  • 0=false
  • 1=true
  • ASKYESNO
  • !=not

Examples

IF-THEN

EQUALTO

//Float comparisons
IF.TrialList.Current.BeamList.Current.Collimator.EQUALTO.#"#180".THEN. InfoMessage="Coll=180"; //If collimator at 180 degrees
IF.TrialList.Current.BeamList.Current.Collimator.EQUALTO.#"#180".THEN.Store.FloatAt.CollFlags=1; //Set variable to 1 if collimator is 180 degrees (these lines can be combined)

STRINGEQUALTO

  • To compare a variable to non-variable string, the format #”#SomeString”. The comparison will not work if #”# isn’t used before the non-variable string.
//String Comparisons
IF.TrialList.Current.BeamList.Current.BeamType.STRINGEQUALTO.#"#Motorized Wedge".THEN.Store.At.CollFlags.Subtract=1; //Subtract 1 if field uses a motorized wedge
IF.TrialList.Current.BeamList.Current.PrevBeamType.STRINGEQUALTO.#"#Static".THEN.InfoMessage= "Static beam type";
Store.StringAt.TXSite="HN";
IF.Store.StringAt.TXSite.STRINGEQUALTO.#"#HN".THEN.InfoMessage = "The Strings Match";

IsNull, !IsNull

  • Use Store.At instead of Store.StringAt in the initial comparison.
Store.StringAt.SearchTerm="testword";
IF.Store.At.SearchTerm.!IsNull.THEN.InfoMessage=Store.StringAt.SearchTerm //Will generate an InfoMessage popup with "testword" displayed
IF.Store.At.SearchTerm.IsNull.THEN.InfoMessage=Store.StringAt.SearchTerm //Will do nothing unless Store.StringAt.SearchTerm="";

Is

  • Appears to work for Pinnacle variables, but not user-created variables like floats and strings.
IF. Scorecard.DoseVolClinicalGoalList.Current. ExpectedRoi.Color. Is. THEN. InfoMessage="ROI does not exist in plan"; //This code checks if a Scorecard ROI is connected to an ROI in the plan.

Contains

  • Appears to only work for user created strings (i.e. Store.StringAt.SomeString)
  • Case-sensitive
  • Use Store.At instead of Store.StringAt in the initial comparison.
Store.StringAt.CTName = VolumeList.Current.Name;
InfoMessage = Store.StringAt.CTName; //For example, displays "RTP HN"

IF.Store.At.CTName.Contains.#"HN".THEN.InfoMessage = "Head and Neck";

Boolean tests

//Variables can be equal to 0 (false) or any value (true) - 1 does not have to be used to signify True.
Store.FloatAt.Test1 = 0;
Store.FloatAt.Test2 = 0;

//Or --> either or both variables are equal to 1 
IF.Store.FloatAt.Test1.OR.Store.FloatAt.Test2.THEN.InfoMessage = "OR = True";

//And --> both values are equal to 1 
IF.Store.FloatAt.Test1.AND.Store.FloatAt.Test2.THEN.InfoMessage = "AND = True";

//XOR --> either variable is equal to 1, but not both variables
IF.Store.FloatAt.Test1.XOR.Store.FloatAt.Test2.THEN.InfoMessage = "XOR = True";

Nested IF

//Nested IF 
IF.Store.FloatAt.CollFlags.EQUALTO.#"#1".THEN={

    IF. TrialList.Current.BeamList.Current.MachineName. STRINGEQUALTO.#"#SomeMachine". THEN. Script.ExecuteNow="/usr/local/adacnew/PinnacleSiteData/Scripts/A_ScriptName.Script";
    IF. TrialList.Current.BeamList.Current.MachineName. STRINGEQUALTO.#"#SomeOtherMachine". THEN. Script.ExecuteNow="/usr/local/adacnew/PinnacleSiteData/Scripts/B_ScriptName.Script";   
};

IF-THEN-ELSE

//One of the two actions is defined in a string
Store.StringAt.SomeAction1 = "InfoMessage = This is a PTV"; //This works for most actions
IF. RoiList.Current.RoiInterpretedType.Is.#"PTV".THEN.Store.At.SomeAction1.Execute.ELSE.InfoMessage="Not a PTV";
  • If both actions are defined in a string, the second .Execute must include ="" (i.e. .Execute=””;)
Store.StringAt.SomeAction1 = "InfoMessage = This is a PTV"; 
Store.StringAt.SomeAction2 = "RoiList.Current.RoiInterpretedType=CAVITY";

//If the ROI type is a PTV, an InfoMessag will display "This is a PTV", otherwise the ROI type will be set to "Cavity"
IF. RoiList.Current.RoiInterpretedType.Is.#"PTV".THEN.Store.At.SomeAction1.Execute.ELSE.Store.At.SomeAction2.Execute="";