LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to write multiple lines string in to one cell

Hi guys,

I have an easy Q. hope u could help me :

 

I have a text box in my uir file, that im tring to read from.

I want the user to be able to write multiple lines - but i want it in one line in one string.

I want it to be one cell in my csv file.

Tried few things - with out any success yet.

 

Now i meneged to write it in to a string that has few lines meanning it hops a line when i try to write it in to a csv file.

Thought i could loop it wiht while loop to find and erase the "\n"- didnt work.

 

thanks in advance.

Adi.

0 Kudos
Message 1 of 3
(4,279 Views)

So basically you want to replace all newline characters with spaces or something else before wtiting the string to a file.

Then you can do the following:

 

#include <ansi_c.h>
static char	msg[64];
static int		i;

strcpy (msg, "123456\n123456\n123456\n456456");   // Dummy content to test the code
while ((i = strcspn (msg, "\n")) < strlen (msg)) msg[i] = 32;

 Above code can be pasted into the Interactive Execution window in order to test it. It replaces newline with spaces: if you want another character, then replace '32' value with the appropriate code or letter (e.g. '*' - note the single quotes)



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(4,272 Views)

Works !!

Download All
0 Kudos
Message 3 of 3
(4,236 Views)