LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do use a control to modify part of string array? Insert into string array?

Solved!
Go to solution

Please see attached graphic.  The two string arrays which I'm trying to maniuplate are circled and the value is highlighted (poorly) in yellow.

 

This is a part of a SubVI on a larger program where I'm addressing three different cDAQ chassis, which are named cDAQ9188-TBL01-Remote, cDAQ9188-TBL02-Remote, cDAQ9188-TBL03-Remote in MAX.

 

I plan to have three separate executables operating at the same time but independently, each addressing a different chassis.  Rather than manually change the single integer and create a new Create_Task 002 and 003.vi for each one, I'd like to have the integer selectable by the user.  Simple 1, 2, or 3 before they start the program and have it inserted into the correct spot (cDAQ9188-TBL0X-Remote where X is the spot).

 

I've managed to insert characters in single strings, but nothing that seems to work with 1d array of string.  Is there a chance for this or should I be building my string arrays entirely differently?

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 1 of 11
(3,706 Views)

I did this which accomplished what I wanted, but that seems like an awful lot of code, and it would have to be custom for each length array I'm working with (there's a few).

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 2 of 11
(3,691 Views)

The pictures you attached don't help very much, so I may have missed your point.  But, here?

 

 Example_VI.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 3 of 11
(3,670 Views)

I just got an error that said too few format specifiers when I tried that.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 4 of 11
(3,661 Views)

I'll try my screenshot for the first post again.  I don't know what happened during that upload.

 

There's two locations - one where the string array is set up to say TBL01 and one where the channel name starts with T1.  Looking for a control way from the front panel to either replace the 1's with 2 or 3, or simply leave the character blank and insert 1, 2, or 3.

 

The second post I have the pictured example seems to work, but it's an awful lot of code.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 5 of 11
(3,654 Views)

Ralph@NES wrote:

I just got an error that said too few format specifiers when I tried that.


Please include a Snippet of your code, or attach your VIs, so that we can better assist you. If you got that error then you didn't do it right... so show us what you did.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 6 of 11
(3,648 Views)

You could have your constants use "%02d" for the number you want replaced and then use a Format Into String to put your number where that %02d is.


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
Message 7 of 11
(3,638 Views)
Solution
Accepted by topic author Ralph@NES

You'll just have to change the 1,2,3,... in your string arrays with the proper format specifier then add the numeric control and two Format Into String nodes and Bob will be your uncle.

 

Example_VI.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 8 of 11
(3,629 Views)

The code jcarmody gave you should do exactly what you want.  But you will need to make sure 'Array' is initialized (Data Operations/Make Current Value Default).  Actually, I expect you'll want it to be a constant instead.

 

The error message means the "%02d" wasn't seen correctly in the 'format' input to the Format Into String.  Maybe the "%02d" was mistyped, not set as default, or you accidentally wired to 'initial string' instead of 'format string'.

 

For the Channel Name, you will need "%d" instead (for one digit).

 

Another approach is to put the three strings you want to choose from in a constant array, then index the constant array using the selection.  For the I/O access, you'll need to use a Build-Array, because it wants an array of strings, not a single element.

 

 

___________________
CLD, CPI; User since rev 8.6.
Message 9 of 11
(3,619 Views)

ZX, they are constants I think, so that example from jcarmody looks like exactly what I need.  Thanks very much, I'll go implement that and see.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 10 of 11
(3,601 Views)