06-23-2011 07:17 AM
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
Solved! Go to Solution.
06-23-2011 07:37 AM - edited 06-23-2011 07:40 AM
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;))
06-23-2011 08:27 AM
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
06-23-2011 09:24 AM
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).
06-23-2011 09:29 AM
Here I rewrote the code
06-23-2011 09:30 AM - edited 06-23-2011 09:31 AM
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
06-23-2011 09:46 AM
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.
06-23-2011 09:54 AM - edited 06-23-2011 09:55 AM
@eximo wrote:
Here I rewrote the code
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.
06-24-2011 07:00 AM
Many thanks, guys. The problem solved!
Sam