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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build a string with mixture of Text, number, space and enter

Solved!
Go to solution

Hi all,

 

I am trying to build a string with mixture of Text, number, space and enter. The content and format of the string should be 'UOL0001 1 2 3' followd by an enter.

Please find it in the attachment, what I am trying to input is ' UOL0001\s1\s2\s3\n'. But it came out wrong. Any idea how to do it? Many thanks.

 

Sam

Download All
0 Kudos
Message 1 of 9
(3,274 Views)
Solution
Accepted by topic author SamGao

Hi SamGao,


Check the following example. Even I don't know what is going wrong with the VI which you made. But to avoid that error, if you want to add a space (\s) or enter(\n) instead of typing it as such, after clicking inside the control just press space bar or enter key once. Then rightclick inside the control and select '\' codes display. Then you will see the \s and \n appearing in the indicator and the code will work fine.


Regards,

Nitzz

(Give Kudos to good Answers and Mark it as a Solution if your problem is Solved;)) 

Message 2 of 9
(3,270 Views)

You're using "Normal display" on your strings, thus "\s" isn't interpreted but written as "\s". R-click the controls and change to "\\ Codes display"

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 9
(3,258 Views)

One curiosity is that you are using array to spreadsheet string?  Why are you doing this?  Why not simply use number to decimal string, for your decimal, and for your enter you can use the carriage return constant.  (these are on the strings menu). 

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
0 Kudos
Message 4 of 9
(3,244 Views)

Here I rewrote the code 

 

format strings.png

 

 

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
0 Kudos
Message 5 of 9
(3,243 Views)

don't forget to dole out some kudos to these guys, and mark this as a solution if it helps, if it doesn't, then try elaborating, we are here to help

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
0 Kudos
Message 6 of 9
(3,240 Views)

You might also consider Format Into String.  It's cleaner on the block diagram and easier to modify if you come back later.  The format string controls the output.  %s indicates a string, %d is a decimal number, %f is a floating point number and the .3 in front indicates I want a precision of 3 digits. \n prints a newline and the spaces between the %<> are printed as is.  There are many other options to the format string.


--Using LV8.2, 8.6, 2009, 2012--
Message 7 of 9
(3,226 Views)

@eximo wrote:

Here I rewrote the code 

 

format strings.png

 

 


Or, you could just do this:

 

 

 

EDIT: I see that taper provided the alternative prior to me being able to finish my post - my post was stuck due to NI server problems.

Message 8 of 9
(3,220 Views)

Many thanks, guys. The problem solved!

 

Sam

0 Kudos
Message 9 of 9
(3,179 Views)