NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

show multiple lines in message popup

Is there a way to write multiple lines in the message popup when the text comes from an ini file. C style escape characters (\n) do not work.
 
An ini file section and key may look like this -
 
[messages]
mess_no_1 = "hit OK when ready \n If not ready hit cancel"
 
This text is read in and TestStand ignores the escape...
 
richjoh
0 Kudos
Message 1 of 7
(7,593 Views)

richjoh -
We would need more information. I assume you are talking about the Message Popup step. If I enter the expression "Your message here \r\n abc"  or "Your message here \n abc" in an expression, the MessagePopup step displays a multiline message, so I would expect that the step type should display the text properly. You might have to post an example for us to look at and let us know what version you are using.

Scott Richardson
National Instruments
0 Kudos
Message 2 of 7
(7,568 Views)

richjoh -
I realized that you might be assuming that if the file text that you read in to a TestStand string property contains the two characters '\' and 'n' you were hoping that TestStand would convert the two characters to a '\n'. TestStand requires control characters to be escaped(\\, \n, \r etc) in an expression string literal because without them TestStand might not be able to parse the overall expression properly. TestStand automatically unescapes control characters in string literals within expressions. Now, a string property value can contain escape characters and you can edit the value in the variables view without have to escape control characters.

If you want to convert the "\n" text to a control character in the string property you can just use an expression function to do this. For example

"Here is my text from my file:\n" + SearchAndReplace(Locals.StringProperty, "\\\n", "\n")

Hope this helps...

Scott Richardson
National Instruments
0 Kudos
Message 3 of 7
(7,559 Views)
hmmm, my example above contains the escape character  like for example "sometexthere \n moretexthere" enclosed in the quotes. If its read into TestStand as a string the escape charactor is ignored.
 
So your saying this only works in TestStand when using an expression string (not a local string variable read from an ini file). Correct?
Message 4 of 7
(7,519 Views)
richjoh,

When you create a static string (such as defining it in the message popup) TestStand expects that there might be special characters you might want to use, so you can use a "\" character to define them. However, when you are using a property object string, TestStand does not expect special characters. It expects the exact string that you type in is the string that you want. Therefore, if you type in a "\" in the variables pane, TestStand interprets it as a literal "\" and not an escape character.

An Example:

Lets say we define a static (literal) string "Hello\nWorld". In memory, TestStand is going to represent it as the character string "Hello\nWorld". Litterally what you typed.

If we define a property object string "Hello\nWorld", in memory TestStand is going to represent it as the character string "Hello\\nworld". TestStand added the second backslash to preserve the characters that you typed in. There is a workaround for this is what Scott showed you above; you can search and replace all of the "\\" you find with just single "\" characters.

Josh W.
Certified TestStand Architect
Formerly blue
Message 5 of 7
(7,511 Views)
I've always just used the chr() function with the value for a new line char in it, like this:
 

"Hello"

+ chr(13) + "world"

0 Kudos
Message 6 of 7
(7,504 Views)

I know this is an old thread, but I found one solution in an NI KB document:

http://digital.ni.com/public.nsf/allkb/78D9AC8EA0C9E978862576CC007825AC

Here is the solution that worked for me (referring to richjoh's original post above). Note that I am using a Locals string variable in my application:

   Locals.mess_no_1 = "" hit OK when ready \n If not ready hit cancel""  >> Note double quotes in string

In the message popup, use the Evaluate command as follows:

   Evaluate( Locals.mess_no_1 )
   
That is the only way I have found to use the \n sequences in the message popup from a variable.

0 Kudos
Message 7 of 7
(6,609 Views)