LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to attach element in array?

Hallo all,

I have a problem with array / cluster ....whatever it's called.

I have a string array , i save it in variable "result".
Suppose "result" is a string array containing :

a b c d e f g
h i j k l m n
o p q r s t u

I want to attach another string that I have saved in variable "aa" and "bb" -->Both variable are string

"aa" containing:
A program to meassure

"bb" containing :
1 2 3 4 5 6 7

I want to mix it all , so it will looked like this :

A program to meassure

1 2 3 4 5 6 7

a b c d e f g
h i j k l m n
o p q r s t u

and then save it to a file.txt

I am using Labview 7.1 , and i've tried to use a express function "creating text" or something like that in english (cos i am using german version).
And i also tried to use function "combine string" , but with both function, i get this :

A program to meassure1 2 3 4 5 6 7 a b c d e f g h i j k l m n o p q r s t u

That function breaks my array , so i can not use it anymore.

Can somebody help me ?
Thank you very much
Andrew
0 Kudos
Message 1 of 9
(3,978 Views)
you just have to add carriage return/line feed characters where you need them when you build up the string. These characters are constants found with the other text related functions.
Randall Pursley
0 Kudos
Message 2 of 9
(3,963 Views)
To add a new element to the end of an array, use the function Build Array. To insert an element anywhere, use Insert Into Array. Both functions are on the Array palette.
Message 3 of 9
(3,957 Views)
Andrew;

I have a VI that write an array of strings to a file, which is a modification of the "Write To Spreadsheet File". You can download it from here:

http://www.jyestudio.com/visecurity/tools.shtml

The name of the vi is Write Strings To Spreadsheet File. I hope this help.

Regards;
Enrique
www.vartortech.com
0 Kudos
Message 4 of 9
(3,936 Views)
Thank you Mr Pursley,

Could you tell me what function should i use ? Because i want to combine 3 string arrays into 1 string array , like i explained before.

Thank you very much

Andrew
0 Kudos
Message 5 of 9
(3,931 Views)
Thank you Mr Knutson ,

I have tried all array function in array pallette, but all this function works with integer/float as input and also give integer/float as output.
I have 2 string and 1 string array and want to combine it into 1 string array as i described before. So i can not use functions in array pallete.
I used the function "combine string" but got an unexpected result (as i described before).
Do you know function that will fit my need ?

Thank you very much
Andrew
0 Kudos
Message 6 of 9
(3,939 Views)
May be you should REALLY try Dennis idea...

CC
Chilly Charly    (aka CC)
Message 7 of 9
(3,925 Views)
I don't think you tried hard enough. If you wire a string array to the first input of the build array and a string to the second input, you will get a string array out with an element appended. You can drag the build array function to create as many inputs as you want. The function is polymorphic which means that it accepts inputs of all data types.
Message 8 of 9
(3,922 Views)
OK, we need to improve the communication before we can help. 🙂


have a problem with array / cluster ....whatever it's called.

I have a string array , i save it in variable "result".
Suppose "result" is a string array containing :

a b c d e f g
h i j k l m n
o p q r s t u

I want to attach another string that I have saved in variable "aa" and "bb" -->Both variable are string

"aa" containing:
A program to meassure

"bb" containing :
1 2 3 4 5 6 7



Terminology is important and you should familiarize yourself with the difference between arrays, clusters and with a simple string made to look like an array on paper (e.g. tab separated values with newline separated rows).

Unfortunately the above ASCII representation cannot tell the whole story. Is your initial array a true 2D array of strings, with a, b, c, etc. each being an array element? You say "bb" is a string. How are the "1 2 3 ..." separated (spaces, tabs, etc.), or is it again an array of strings?


And i also tried to use function "combine string" , but with both function, i get this :

A program to meassure1 2 3 4 5 6 7 a b c d e f g h i j k l m n o p q r s t u

That function breaks my array , so i can not use it anymore.

What do you mean by "use it"? Once it is written to a file, everything is just a collection of characters, i.e. a single long string. The concept of "array" ceases to exist. To make sense of the data, the string needs to be structured (a) that the original array can be reconstructed by another program reading the file and/or (b) so it looks like an array on paper or in notepad.

Is your primary purpose (a) or (b)? If (b), also try to use e.g. wordpad instead of notepad. If you would only use a "newline" character to separate lines, notepad will not wrap (it only wraps at \r\n combo), but wordpad will correctly display unix-type text files.


Arrays are often formatted as "spreadsheet strings", with elements separated by tabs and rows separated by linefeeds. However your string is mixed, containing also title lines hat should not be interpreted as array elements.
This is important information for case (a) because you need the first few lines as strings before reading the rest of the file as spreadsheet array.

It would be much easier to understand your problem if you could attach a simple version of your code. It would remove many of the ambiguities mentioned above.
Message 9 of 9
(3,905 Views)