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: 

create 2d string

I can't seem to find the right function for it. Tried using express table but can't use string data for dynamic data, Table is a user input, tried looking for other tables. 

 

 

I have a loop that iterates through two types of string arrays, the address and the name. For each iteration I want to put it in a table.

Simple enough but can't seem to find the right function for it. =/

 

Any suggestions?

 

Thanks,

William

 

0 Kudos
Message 1 of 8
(2,569 Views)

A table is a 2D array of strings.

 

If you have two 1D arrays of equal length containing matching elements, all you need is to use "build array". After that, you might want to transpose before writing to the table indicator.

 

If this does not help. please show us your code. Make sure the two input arrays contain typical default data (make current values default before saving).

0 Kudos
Message 2 of 8
(2,568 Views)

I tried using the Table function but it doesn't allow me to specificy the index and insert the element.

 

The Build Array function seems to only accept double and not strings.

 

Is there a way to change the data type of an array?

0 Kudos
Message 3 of 8
(2,564 Views)

When you wire a string to the Build Array, it will automagically change the data type to a string.  Give it a try.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 8
(2,559 Views)

I see, that would work if I knew the number of elements.

Is there a function that appends, to a current string each time?

 

What I am essentially trying to do it:

 

numElements = (specified by user);

 

for ( i = 0, i ==NumElements-1, i ++)

{

stringArray(i,0) = GPIB_Adress_List(i);

stringArray(i,1) = IDN_List(i);

}

 

display(stringArray);

 

I sort of got this down in LabView except I am not sure how to put it in the "stringArray".

String.png

 

Does the build array function have another option that I don't see that would be able to do this?

0 Kudos
Message 5 of 8
(2,552 Views)

You should be using the Autoindexing on the FOR loop.  It makes life a lot easier.  Try something along these lines.  It is far from perfect, but it will hopefully get you over the hump.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 8
(2,533 Views)

Oh nice.

Just started LabView so I have many things to learn. I'll look into autoindexing.

I was wondering if you are able to upload the .vi for the example that you've shown or rather what these certain functions are

VISA abc --> W 

VISA abc <--- R 

two boxes --> { many boxes

 

Thanks,

William

0 Kudos
Message 7 of 8
(2,501 Views)

Actually, that picture is called a snippet.  Save it to your machine and then drag it onto an empty VI.  And the code will automagically appear.

 

Since you seem quite new, I would recommend taking the online tutorial: LabVIEW 101


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 8
(2,490 Views)