From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Editor >> Find and Replace text - can replacement string include a newline character?

Solved!
Go to solution

When using the Find and Replace function within the LabVIEW editor, is it possible to include a newline (line feed) character within the replacement string?

0 Kudos
Message 1 of 12
(4,402 Views)

Have you tried it?  Using a '\n'?

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 12
(4,390 Views)

I can't think of any reason why not.  Did you try it?  Hint: make a test VI with just the Find And Replace function and the inputs you want and see what happens.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 12
(4,370 Views)

Yes, I did try that before I asked the question. The net result was that the two characters, "\" and "n" were inserted instead of a newline character.

0 Kudos
Message 4 of 12
(4,355 Views)

Right-click the string constant and change to " '\' Codes Display " first, then put in "\n".

 

Note that this will change all of your spaces, tabs, etc in that string to \s, \t, and so on.

Message 5 of 12
(4,343 Views)

@Kyle97330 wrote:

Right-click the string constant and change to " '\' Codes Display " first, then put in "\n".

 

Note that this will change all of your spaces, tabs, etc in that string to \s, \t, and so on.


You do realize that this is the text entry box that's being discussed here?

What you suggest does not work.

 

Clipboard01.png

0 Kudos
Message 6 of 12
(4,331 Views)

I think what Kyle is saying is that once you turn on special codes display, the replace will work as you intend.  The search function apparently only looks at what is visible in the control.  If special codes is turned on, it will search and replace just fine.  If they are turned off, it doesn't interpret '\n' as a newline and you will get unintended results.  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 7 of 12
(4,326 Views)

It would be more trouble to go through the project and turn on (& later turn off) the special codes display in the 100+ places where I want to make the change than it would be to make the change manually after just doing a FIND.

0 Kudos
Message 8 of 12
(4,322 Views)

Agreed but this is potentially do-able via scripting.  Is this a one-time thing or something you forsee having to do frequently?  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 9 of 12
(4,319 Views)
Solution
Accepted by topic author WNM

One time, I hope. 

I just thought that there might be a simple way to do it that I was missing.

It really sounds like there is not.

 

I can do it manually in less time than it would take to create a script and get it working right.

 

0 Kudos
Message 10 of 12
(4,316 Views)

This snippet will turn on codes display for all string controls in a VI.  It will try to cast everything into strings but I just clear the error and move on.  

NOTE: I would not run this on your working copy unless you have a backup.  Just sayin'.....

 

Example_VI_BD.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 11 of 12
(411 Views)

If you are mucking with the display style, make sure to make the display style visible.  Many issues can be quickly figured out with that turned on.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 12 of 12
(389 Views)