01-19-2013 07:35 PM
Where can I find how to put a literal string into an expression? When I search for TestStand string literal, I find nothing.
Thanks.
01-21-2013 06:35 AM
I'm not totally sure what you mean by literal string, but I'm thinking you just need to put quotes around your string.
01-21-2013 08:17 AM
By literal string, I mean don't unescape any slash codes.
01-21-2013 08:20 AM - edited 01-21-2013 08:21 AM
@StephenGerads wrote:
By literal string, I mean don't unescape any slash codes.
Ah. Yeah, I've had that problem as well. I ended up just using the double slash (\\) whenever I had a slash in my string. I hope there's a better solution.
01-21-2013 08:23 AM
I know there is a way to do it in the newer TS versions. I wish details were easy to locate with search "TestStand literal string".
01-21-2013 09:37 AM
You can either use double back-slashes (to escape the backslashes themselves), or, in TestStand 2012 and higher, you can use the @ symbol before the string literal to avoid the unescaping. For example:
@"my string w\ith\ backslashes"
The following is from the expression browser help in the "Operators/Functions" tab under Constants->Other:
"Add an '@' before the enclosed quotes to turn a string constant into an unescaped string constant. Unlike for regular string constants, backslashes are left as is instead of specifying an escape sequence. Use "" for " within an unescaped string constant."
Hope this helps,
-Doug
01-23-2013 03:45 PM
Alternatively, you can use the RunState.Engine.Utility.Escape() method to emulate the behavior of the "@" symbol in TestStand 2010 SP1 and earlier:
RunState.Engine.Utility.Escape("\test",0)
01-23-2013 07:53 PM
Al B,
Can you arrange to have it easy to find this information in help?
Thanks.
Steve
01-23-2013 11:22 PM - last edited on 11-01-2024 07:09 PM by Content Cleaner
Hi Steve,
For future TestStand versions, we would recommend using the "@" approach as mentioned by dug9000, so there are no plans to further document the escape method I mentioned. However, you can find information on expression operators and functions in the TestStand help (Expression Functions and Expression Operators topics) or in the description field within the expression browser.
01-24-2013 10:56 AM
Hi, I did a bit more testing with the utility.escape method I suggested, and it doesn't behave exactly in the same way as the "@" operator like I originally stated. The difference is in the case when a backslash is not forming a special character. In this case, the unescape method adds an additional backslash, for example:
Both of these results will work with a file open operation, but I would suggest using the "\\" method with TestStand 2010 or earlier rather than the unescape method just to be sure you are not getting unexpected double backslashes.