String Variables
Declaration
Store.StringAt.SomeStringName = "This is a string"; //Ex 1
Store.StringAt.AnotherStringName = TrialList.Current.BeamList.Current.PrevBeamType; //Ex 2
Store.StringAt.String3 = Store.StringAt.SomeStringName; //Ex 3
//Ex 4 - This also works, but requires much more typing.
Store.At.TempString = SimpleString {
String = “Hello strings”;};
Actions
Append
It is necessary to use the "Store.At." form of the variable instead of "Store.StringAt." when appending to the variable.
Store.StringAt.ExampleString = "This is "; //Variable ExampleString = "This is"
Store.At.ExampleString.AppendString = "a test."; //Variable ExampleString = "This is a test."
Store.StringAt.ExampleString = "This is "; //Variable ExampleString = "This is"
Store.At.ExampleString.AppendString = Store.StringAt.Something;
Boolean Tests
Contains
- Must be written with a capital "C" and lower case "ontains'
- The test is case sensitive. The string must contain the word exactly.
- Use Store.At instead of Store.StringAt. in comparison
Store.StringAt.SomeString = "What are you up to?";
IF.Store.At.SomeString.Contains.#"you".THEN.InfoMessage = "The string contains the word you";
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.
IsNull
- Checks to see if a string exists, but contains no text
- If the string has not yet been declared, it will not be found NULL.
- This test is case sensitive. Make sure you use IsNull and not ISNULL.
- Use Store.At instead of Store.StringAt in the initial comparison.
- !IsNull doesn't seem to work correctly at times (P14+?).
Store.StringAt.SearchTerm="testword";
IF.Store.At.SearchTerm.!IsNull.THEN.InfoMessage=Store.StringAt.SearchTerm //Will generate an InfoMessage popup with "testword" displayed (doesn't seem to work in P14?)
IF.Store.At.SearchTerm.IsNull.THEN.InfoMessage=Store.StringAt.SearchTerm //Will do nothing unless Store.StringAt.SearchTerm="
STRINGEQUALTO
Comparing a string directly:
IF.TrialList.Current.BeamList.Current.PrevBeamType.STRINGEQUALTO.#"#Static".THEN.InfoMessage= "Static beam type"; //For direct string comparison use syntax #"#Any String"
Comparing a variable:
Store.StringAt.TempPos = "On back (supine)";
IF.PatientSetup.Position. STRINGEQUALTO. Store.StringAt.TempPos. THEN. InfoMessage= "Patient position is supine";
Comparing two strings:
Store.StringAt.ContourOnOff=RoiList.Current.Display2d;
String.StringAt.Off="Off";
//Use "StringAt" for string comparison
IF. Store.StringAt.ContourOnOff. STRINGEQUALTO. Store.StringAt.Off. Then.Infomessage="ROI off";
//Or compare to "Off" directly as demonstrated above
IF. Store.StringAt.ContourOnOff. STRINGEQUALTO.#"#Off". Then.Infomessage="ROI off";
STRINGNOTEQUALTO
Store.StringAt.TempPos = "On back (supine)";
IF.PatientSetup.Position. STRINGNOTEQUALTO. Store.StringAt.TempPos. THEN. InfoMessage= "Patient position is prone";
Typecast to Float Variable
Unlike typecasting from Float to String, the variables must use the full variable definition "FloatAt" and "StringAt"..
Store.StringAt.Text=7;
///------*****This step typecasts****
Store.FloatAt.Number = Store.StringAt.Text;
//----------
Store.At.Number.Add=1;
InfoMessage = Store.At.Number;
Free a string variable
- To delete a float variable use the FreeAt command.
- Unless utilized by another script, all variables should be freed when the script is done running.
- It can help prevent memory leaks and other issues with variable.
Store.FreeAt.TempString = "";