What are Expression Strings in TestStand? Primary Software: TestStandPrimary Software Version: 1.0 Primary Software Fixed Version: N/A Secondary Software: N/A
Problem: What are expression strings in TestStand? Solution: Overview TestStand built-in step types contain properties that are instances of the String data type. While TestStand uses most of these properties for normal string values, some of them store an expression string. This document describes expression strings, which will help you avoid common run-time errors when you directly modify properties containing expression strings. Table of ContentsDefinitionAn expression string is a string that represents an expression that TestStand evaluates at run time. The result of the evaluation must be a string value. In other words, a step property that is used for an expression string, rather than for holding a literal string that TestStand evaluates at run time, holds an expression string whose run-time evaluation returns the literal string value. ExampleThe title of the Message Popup step type is stored in the property TStep.TitleExpr as an expression string. This expression string is normally set in the TStep.TitleExpr property when you fill out the Title Expression control in the Configure Message Box Step dialog box, as shown in the figure below. Notice that the title expression below is a concatenation of a literal string enclosed in double quotes, and a numeric value that is converted to a string. When this expression string is evaluated, it returns a single string that is used as the title (e.g. TITLE NUMBER 5). You also can dynamically change the message popup title by programmatically assigning a new expression string to the TStep.TitleExpr property. One way to make this change is through the Pre Expression control of the step, as shown in the figure below. When you make this assignment, enclose all literal string values in double quotes. If they are not enclosed in double quotes, they will be interpreted as names of properties. In the example scenarios below, the final desired title is New Title. Scenario 1 To change the message popup title, make a literal string assignment to the step property in the Pre Expression. A common mistake is to use the following syntax: Step.TitleExpr= "NewTitle" If you make this assignment, the value of the TStep.TitleExpr property contains the value NewTitle. Since this value is not enclosed in double quotes, NewTitle is interpreted as the name of a property rather than a literal string. A run-time error will occur if there is no property named NewTitle. Another common mistake is to make the following assignment: Step.TitleExpr= ""NewTitle"". In this case, TestStand cannot determine the correct beginning and ending quotes in the assignment. The second double quote incorrectly marks the end of the assignment value. You must precede any quotes within a string with a backslash. The following is the correct assignment for a literal string. Step.TitleExpr="\"NewTitle\"". After this assignment, the value of the TStep.TitleExpr property contains the characters "NewTitle", which will be interpreted correctly as a literal string. Scenario 2 You also can assign Step.TitleExpr the value of another string property, as shown in the following assignment: Step.TitleExpr=Locals.MyString. A common mistake is to assign the value of Locals.MyString to be NewTitle. After this assignment, the value of the TStep.TitleExpr property contains the value NewTitle. Since the value is not enclosed in double quotes, it is interpreted as a property named NewTitle instead of a string value. To solve this problem, use one of the following three solutions:
Expression String Properties in TestStand Built-in Step TypesThe following is a list of step type properties that are used for expression strings. All other string properties are used for normal string values. For normal string values, you do not need to use a pair of double quotes for the value to be evaluated as a literal string. Step Type Property Name ---------------------------------------------------------------------------------------------------- Message Popup TitleExpr MessageExpr Button1Label Button2Label Button3Label Button4Label Call Executable Arguments Property Loader Database.SQLStatement Database.StepNameColumn File.FileExpr File.StartMarkerExpr File.EndMarkerExpr Open Database ConnectionString Open SQL Statement SQLStatement NI_DataOperation SQLStatement IviDmm Readings.TimeoutStatus Readings.IsOverRangeStatus IviScope Readings.TimeoutStatus IviTools Init.OptionsString Related Links: TestStand Reference Manual Using TestStand Attachments:
Report Date: 04/02/2007 Last Updated: 06/20/2007 Document ID: 481A3MQA |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
