04-26-2011 07:03 AM
for(imstuck) wrote:
My arrays should really all be outside the for loop, with autoindexing disabled as necessary
Of course... 😉
04-26-2011 08:05 AM
@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. 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.
Okay, the confused guy is back.
In regards to Richard's initial comments and suggestions (Message 8 and below), I tried this solution, but it contained one major flaw. My output error array (and you are correct, I am looking for an array) shows all of the errors and labels. The labels are appended to the error array as hoped, but for the errors that are blank I still have the sensor label. So my output array looks something like:
Sensor Label 1 - Output Error 1
Sensor Label 2 -
Sensor Label 3 - Output Error 3
Sensor Label 4 - Output Error 4
What I'm trying to do is get rid of the 2nd element in that example completely. I'm concerned that perhaps it is because I am defining the blank sensor errors in MATLAB and they actually aren't blank, but are rather a single character of a space. Perhaps there is either a way to take this into account or to change the error in the MATLAB script so that it is more LabVIEW friendly?
I have not tried the other method proposed, but it sounds that I need to use the combination of the 2 methods proposed by "for(imstuck)" (which is a great name BTW). One thing I don't fully understand about this method is what is going on with the 1-D Search Array function? I'm thinking that perhaps this is meant to cross-reference my output error array with a set error array that includes all of the errors I I could have.
If this is true, the problem with this is that each element of the array is unknown and can be infinite different possibilites. (Each element of the array says something like: "Warning: Sensor value ## exceeds (lower or upper) limit: ##" This is simply one option the error can have. It can also have 2 other forms not including the blank space, but the point being that I cannot simply cross-reference my array with another array and remove the blank entries.)
04-26-2011 08:30 AM - edited 04-26-2011 08:30 AM
You can scale up from Altenbach or for(imstuck)'s proposed solution.
For instance, you can use a Format Into String function to customize the error message.
Are you trying to automatically build up a list of error codes based on whatever new error message that your code encounters?
Have you started implementing your own solution? If so, can you post what you have so far?
04-26-2011 08:31 AM
@twolfe13 wrote:
If this is true, the problem with this is that each element of the array is unknown and can be infinite different possibilites. (Each element of the array says something like: "Warning: Sensor value ## exceeds (lower or upper) limit: ##" This is simply one option the error can have. It can also have 2 other forms not including the blank space, but the point being that I cannot simply cross-reference my array with another array and remove the blank entries.)
You simply need a trivial modification:
04-26-2011 08:46 AM
The program is implemented as a script node in LabVIEW. It inputs the sensor data and checks the following things:
a) If the sensor is in range it does nothing (outputs a blank entry into my error array)
b) If the sensor is approaching the limit by a specified percentage, it gives a caution and outputs the sensor value and the limit it is approaching in the string.
c) If the sensor is beyond the limit, it gives a warning and outputs the sensor value the limit that has been exceeded in the string.
d) If the sensor is NaN or zero is outputs that the sensor may be disconnected or not reading properly.
So because the string may includes the sensor value (a double precision number), I cannot use a lookup table to cross-reference the array.
Also, I apologize for not uploading my program. I am using a government issued computer and there is this lovely rule where we can't use USB drives to transfer data from the computer I'm using to the computer I'm using for internet access. (Actually it's more complicated than that since I can transfer the data, but then it become encrypted which is of no use to anyone except myself when that occurs.)
04-26-2011 08:56 AM
Try something like this:
04-26-2011 08:56 AM
Okay. Simple solution to my problem from earlier with Richard's program. I simply replaced the "Empty String/Path?" comparison tool with the "White Space?" comparison tool and it worked like a charm. Thanks very much for everyone's help!
04-26-2011 09:00 AM
@twolfe13 wrote:
So because the string may includes the sensor value (a double precision number), I cannot use a lookup table to cross-reference the array.
OK, search the string for certain key words, e.g. using "search string" or "scan string for tokens" and parse the number depending on the outcome.
Can you at least upload a simple test file containing typically encountered strings?
04-26-2011 09:55 AM
@altenbach wrote:
Try something like this:
- ... spurious ...
Kudos for teaching me a new word.