LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a "smart" String Output to the Front Panel

Solved!
Go to solution

Hello all,

 

I don't use strings all that much and I've gotten myself into some coding that seems to be a bit beyond my skillset at the moment.

 

Let me explain. Right now I have a 1-D array of strings. Each string denotes an error with a sensor. If there is no error, then the string is simply a blank space (the strings were generated in MATLAB and imported into LabVIEW. To define an empty string in MATLAB I simply did something like: error = ' ')

 

Right now, the strings are very generic and do not specifiy which sensor they go to. I would like to change this by introducing some sort of data for these labels. (One possibility I've considered is importing a spreadsheet file with the labels in a column and having that data converted to a 1-D array of strings, or something like that. It seems like there should be multiple ways to achieve this and I'm open to any solutions really.)

 

What I would like to do, is match those two sets together, and if there is no error, then that row would be removed from both arrays. Ideally I would also merge the two arrays so that I have a label followed by what the error is for that label output on the front panel.

 

Perhaps there is an easier way to do all of this that I haven't considered. Like I said, I'm open to any suggestions. But basically, I want to only display the sensors that actually have errors associated with them.

0 Kudos
Message 1 of 19
(3,826 Views)
Solution
Accepted by twolfe13

If I understand what you want correctly, here is one solution (see the attached png). The For loop goes through the arrays and produces an output array of strings. If the Error string is empty then nothing is added to the output array. If the Error string is not empty then the Error String has the Label string concatenated and the result is appended to theoutput  array. For the data shown the output array would have 4 entries:

 

Error 1 Sensor name 1

Error 2 Sensor name 2

Error 3 Sensor name 3

Error 4 Sensor name 4

 

 

Message 2 of 19
(3,808 Views)

You could just do a lookup table as follows:

 

Download All
Message 3 of 19
(3,803 Views)

Hello twolfe13

 

Have you made any progress on your issue?  I'd be more than happy to help you.  Can you let me know if the solutions provided by our respected forum members have allowed you to solve your issue?  Please let me know and I can further assist you with this issue.

 

Thank you for your support of National Instruments!

 

Sincerely,

 

Greg S.

Sincerely,

Greg S.
0 Kudos
Message 4 of 19
(3,760 Views)

Greg,

 

Thank you for your help. I'm still trying to determine if one of the solutions provided solve my problem. I'll be sure to reply to the thread with further details. If nothing else, they have certainly been helpful in solving my question.

0 Kudos
Message 5 of 19
(3,756 Views)

Thank you very much for your response.  I look forward to your success or helping you achieve it!

 

Sincerely,

 

Greg s.

Sincerely,

Greg S.
0 Kudos
Message 6 of 19
(3,750 Views)

Altenbach beat me with his elegant solution example. 

 

That is the way I would proceed.

0 Kudos
Message 7 of 19
(3,734 Views)

I agree that it is an elegant solution, but I don't think it does what the user wants. The initial poster said that he has an array of strings coming in, and wants an array of strings going out, with those entries corresponding to incoming empty strings removed. Each retained array entry should have a corresponding sensor identifier added. In the snippet below the "Error Strings" array is the user's incoming array of strings and Output Array is the output. Each non-blank incoming entry has the sensor label attached and is appended to the output array. Blank entries in the incoming array are dropped and do not appear in the output array.

 

code snippet

Message 8 of 19
(3,725 Views)

@Richard2950 wrote:

I agree that it is an elegant solution, but I don't think it does what the user wants. The initial poster said that he has an array of strings coming in, and wants an array of strings going out, with those entries corresponding to incoming empty strings removed.  

 


The user could just put altenbach's code in a for loop, autoindex the incoming array as the received error string, then use build array with a shift register to build the array going out. Simple.

 

Give Altenbach the credit for this one but here is an example of this simple modification.

 

 

 

Low hanging fruit, FTW.

Message 9 of 19
(3,720 Views)

@for(imstuck) wrote:

@Richard2950 wrote:

I agree that it is an elegant solution, but I don't think it does what the user wants. The initial poster said that he has an array of strings coming in, and wants an array of strings going out, with those entries corresponding to incoming empty strings removed.  

 


The user could....


My arrays should really all be outside the for loop, with autoindexing disabled as necessary Smiley Surprised
0 Kudos
Message 10 of 19
(3,711 Views)