LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to append a string to another string?!

Solved!
Go to solution

Hi,

 

  I have a program which is reading a string of data ( included from 9 columns) from a subVI ( Microcontroller)  and another string of data (1 column) from another subVI ( Temperature chamber) .then I wanna joing these two parts together in a way that at end I have 10 columns of data that I have to write them in one text file.

the thing which I have done writes the second part in an individual line of data and can not join them together. I don't know wether it's because of syncronisation or sth else.because time is one column of data which microcontroller gives me.

sry if I can not explain my problem good,because I am beginner yet.

 

anybody help me ?!

 

thanks 🙂

0 Kudos
Message 1 of 10
(10,213 Views)

What is your definition of a colum? Do you have special delimiters? Is this a single string or arrays of strings?

 

In a string table, lines and rows are defined by their delimiters, so all you need is assemble the fileds correctly before writing all 10 columns to disk.

 

Show us your code with some typical string data in diagram constants.

0 Kudos
Message 2 of 10
(10,208 Views)

first part of data includes 89 characters which all are in one line like below and I receive it each second from Microcontroller:

 

2837     0.0     0.0    35.5    34.5  0x16776706  0x16776765  0x00000114  0x00000112

 

and as you see there are space between numbers (which I call it 9 columns) but I receive all these data just in one string line. this string comes from one SubVI and now I want to add one more column to this string line from another SubVI. which is like ;

 

25.2

 

in other word I want to have the below line in my text file( which will be 10 columns ;

 

2837     0.0     0.0    35.5    34.5  0x16776706  0x16776765  0x00000114  0x00000112  25.2

 

I think even if I send my VI ,it won't make any sens.

 

 

0 Kudos
Message 3 of 10
(10,195 Views)

@worldviol wrote:

I think even if I send my VI ,it won't make any sens.


Of course it would!

 

So you get one long string and one short string per second. Simply use "concatenate string" to merge them into one, then write to file as one row.

0 Kudos
Message 4 of 10
(10,188 Views)

exactly I just used "concatenate string" but when I want to wire the output to "write to spreadsheet file" it does not match and gives error!!

0 Kudos
Message 5 of 10
(10,183 Views)
Solution
Accepted by topic author worldviol

You are using "built array" instead of "concatenate string".

 

Since you already have an entire row to write consisting of a single string, you need to add a "build array" if you want to use "write to spreadsheet file" (see image below). You should change the format to %s. It would be easier to use plain file writes, after appending a linefeed to each row data.

 

What's up with all these local variables? Your VI is full of race conditions, for example if the program starts you write to certain globals at the same time you read from the same globals. Because the execution order is not defined, the results will differ unpredictably. Use plain wires!

 

0 Kudos
Message 6 of 10
(10,175 Views)

thank so much for help,you are right.

I know that there are many mistakes in my programming but I am as intern and they ask me just to have result and they don't give me time to work on my program to develop it. thats why It is not so organized.

Actually now I see that there is another problem that in my text file I have one line of first part string without the appended sstring from 2nd SubVI and after that in next line I have the same but this time the appended string is in next line, as below;

 

   6655     0.0     0.0    36.0    35.5  0x16776766  0x16776718  0x00000102  0x00000111

   6655     0.0     0.0    36.0    35.5  0x16776766  0x16776718  0x00000102  0x00000111
25.2

 

 

do u now how can I solve it  ?!

thanks again

0 Kudos
Message 7 of 10
(10,170 Views)

As mentioned above, just use concatenate string. Hope this helps.

 

concatenate.png


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 8 of 10
(10,151 Views)

thanks aCe;

 in fact both are my solution but I don't know how should I make both answer Accepted as solution. But your answer is also one part of my solution.

but still I have this problem that why I have one line extra in between 😞

0 Kudos
Message 9 of 10
(10,135 Views)

@.aCe. wrote:

As mentioned above, just use concatenate string. Hope this helps.


Your use of "spreadsheet string to array" makes no sense here, because that funtion is immediately undone inside "write to spreadsheet file" (you can open it and look at the code). What is your resoning to do it this way? Seems duplicate and convoluted!

0 Kudos
Message 10 of 10
(10,115 Views)