08-25-2015 07:46 AM
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?
Solved! Go to Solution.
08-25-2015 08:29 AM
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).
08-25-2015 09:11 AM - edited 08-25-2015 09:15 AM
08-25-2015 09:21 AM
I just got an error that said too few format specifiers when I tried that.
08-25-2015 09:24 AM - edited 08-25-2015 09:27 AM
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.
08-25-2015 09:27 AM
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> ---'
08-25-2015 09:34 AM - edited 08-25-2015 09:35 AM
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.
08-25-2015 09:35 AM
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.
08-25-2015 09:43 AM
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.
08-25-2015 10:33 AM
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.