From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
11-24-2011 06:50 AM
Hi
I have a named array of containers. I like to increase the arry if the name is not present in the
array. For doing this i am using the PropertyObject members.
This is working well if you are using strings without 2 or more "\" (Backslash).
So whats the reason.
I have used. T4.5 and 4.2
Regards
Juergen
Solved! Go to Solution.
11-24-2011 07:01 AM
can you post a 4.2 example?
11-24-2011 07:33 AM
11-24-2011 07:59 AM
Its probably because \T puts a tab in your string whereas \M does nothing.
If you do \\T then the Exists() is True and it doesn't add it again.
11-24-2011 09:24 AM
HI Ray,
Thanks for testesting "\\T". Have also tought about this.But not tested, because i am getting string from TS itself.
It is the path from DLL CodeModule apater. So my opinion is that TestStand should handle the "\" stuff internally.
My workaround was just replacing the "\" with a "/".
Regards
Juergen
11-28-2011 10:52 AM
The backslashes for escaping only apply to string literals in expressions. In all other cases they do not apply. If you take a string from somewhere else and try to convert it into a string literal for an expression you need to escape it (i.e. all backslashes should be escaped with another backslash and all quotes should be escaped with a backslashes, and potentially carriage returns and linefeeds and tabs should also be escaped). Also, there is a function in the engine that will do this for you, Engine.Utility.Escape().
Hope this helps clarify things,
-Doug
11-29-2011 12:27 AM
Hi Doug,
Thanks for pointing out.
Engine.Utility.Escape() is exactly what i need.
Just a note. I was getting the string from Engine.FindFile()
It would be nice to add a remark to function's help in future relase that founded string should be escaped.
Regards
Juergen
11-29-2011 10:29 AM
The issue is, the string returned by FindFile doesn't necessarily need to be escaped. The escaping is only necessary when you are creating a string literal in an expression. It really doesn't have anything to do with FindFile because in all other cases there is no escaping so FindFile returning an unescaped string is no different than anything else returning a string. How exactly are you using the string? Maybe what should be documented or looked into is that the way in which you are using it requires escaping.
-Doug
11-30-2011 12:42 AM
Hi Doug,
Upps, I told you something wrong!!! Engine.Find() File is NOT the problem here.
Excuse me.
The problem is as mentioned in topic on named arrays:
Here is the way iam getting the string.
1. Statement
// Modul Name
Locals.strFileName = Locals.hModule.AsCommonCModule.ModulePath,
// Lookup String
Locals.strArrayName = Locals.strFileName,
// Workaround
SearchAndReplace(Locals.strArrayName ,"\\","/"),
Locals.strLookup ="[\""+Locals.strArrayName+"\"]"
If Expression:
!Locals.objModules.AsPropertyObject.Exists(Locals.strLookup ,0)
2. Statement
// Set Array Elements name
Locals.pObj.AsPropertyObject.Name = Locals.strArrayName,
Regards
Juergen
11-30-2011 10:07 AM
I see that it's lookup strings of the format:
MyarrayVar["elementName"]
where the escaped string is also expected. This is similar to the string literal in expressions case. Generally, if you are adding the quotes for a string, then the contents between the quotes likely needs escaping. I've logged a request to update the documentation for lookupstrings to mention this issue and explain about escaping strings.
-Doug