IF-THEN | IF-THEN-ELSE Statements

Description

The IF-THEN statement is used to "test" an object and then execute a command based on the result. If the test is true, then the action will occur. Otherwise, no action will be performed.

Syntax

  • 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;
...
};

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

Store.StringAt.tempstr = "PTV";
IF.RoiList.ContainsObject. Store.StringAt.tempstr. THEN.InfoMessage="Contains the ROI";

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 existence tests, but not user-created variables.
!IsNull should work like "Is" user for user-created variables (sometimes?!)
CONTAINS

Boolean-specific tests

AND
OR
XOR

Special values

0=false
1=true
ASKYESNO
!=not

Examples

Float

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)

String

STRINGEQUALTO

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

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 values, 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.

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/A_ScriptName.Script";

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