10-17-2016 01:09 PM
Raven,
I was using the Array Size function as you mentioned. I also realize the race condition now. However, when I probe my "size(s)" results from the Array Size function, it stays at a constant "7", even though different messages are still coming in. Otherwise I think your method would work. My previous post has my code in there, with a slight change, adding back in the "Array Size" instead of "String Length"...
And no, I haven't looked at those tutorials yet, but I will very soon when I have time.
Thanks,
SM
10-17-2016 01:15 PM
PLEASE PLEASE PLEASE take the tutorials.
Try to understand what your code actually does. Until you understand how it works now, you are not going to understand how to make it work the way you want. And just throwing chunks of code in there from several sources at once is not going to magically make it work.
Put probes in. Run it with execution highlighting turned on so you understand what data flows where down the wires.
The problem is you are taking the current row and indexing that out. Then you check the array size of that which is always 7 because you probably have 7 columns in that original 2-D array of data.
10-17-2016 01:21 PM
@Sman29 wrote:
Unfortunately I cannot post my code for a couple reasons, mainly proprietary... Attached is a screen shot of kind of where I am at right now though.
OK, let's look at your image:
This has very little resemblance with my code.
Run my code, do some probing and execution highlighting, read the help for the various primitives. Understand how and why it works!
10-17-2016 01:23 PM
Raven,
I will indeed take the tutorials when I have time. Right now I was just thrown to the wolves on a massive program, and they just spit code at me and tell me "to modify it by tomorrow" type deal... Leaving me no time to actually learn it. The guy that built this program has been doing LV for over 10 years (and is out of pocket), whereas I've had distracted few months towards LV... Yes, I know it's terrible coding practice to do it this method, but that's the situation I am in right now. It will get better soon, but for now, I just have to put stuff together and make it "magically" work... I only posted the question on here because I thought it would be a simple thing to add. Apparently it isn't. Or is if I know what I'm doing but I don't... Which is why I come to you guys for help 🙂
Regarding your comment: "The problem is you are taking the current row and indexing that out. Then you check the array size of that which is always 7 because you probably have 7 columns in that original 2-D array of data."
I thought I did it as you had said? Please tell me what I need to change as far as the array size stuff goes...
Thank you guys for your help and patience with me!
SM
10-17-2016 01:31 PM
Alten,
"This has very little resemblance with my code.
By outer loop I am assuming you are talking about the outer WHILE loop? I am not sure how to do that since all the stuff I need is inside the case structure?
"Test Plan Table" is actually the messages being sent that I need to record. Basically it's just this giant csv that "executes" the elements row by row. Everytime it executes a row, I want to record that row. So if the program crashes, I know what row I was on.
I placed the close file outside the loop per your suggestion.
Where do I need to substitute my own message at? I thought I had done that by adding my string to the "Replace Array Subset"?
Thanks,
SM
10-17-2016 01:45 PM
10-19-2016 08:48 AM - edited 10-19-2016 08:56 AM
Alten,
I eleminated the "last 5 messages" per your statement that it was just for debugging.
I wired in the "current step" to the "Initialize Array". I am assuming that was where you meant my "message" to go?
I placed the "close file" inside the loop and the "create file" outside the loop.
I did not need to wire anything outside the loop since I brought everything inside or eleminated it.
It still is not working... Please see attached and tell me what I did wrong...
Is it not just easier to read the last 5 messages from my file that I am already writing to? I am currently writing every message received to a file. Raven attempted to help me read the last 5 messages from that file, but I couldn't get it to work either...
Thanks for the help and your patience!
SM
10-19-2016 09:21 AM
New update:
So I got it to read the last 5 messages of the file that records all of the messages. I made a slight alteration to Raven's code. Attached is a screenshot of how my code is now.
The only problem with this is, the index for the array subset (circled in red in the screenshot) is based off of what row number has been executed. When the program crashes, I have it set up to stop execution and jump to the first row. This makes my index jump back to 0, making my "Read from File" read the first 5 messages...
Is there a way to get it to hold its value of row number until the "start" button is pressed again (starting execution at row 1 again)?
Thanks for all the help guys, almost there!
SM
10-19-2016 10:54 AM
Moved my last question to a new thread since the subject has changed:
http://forums.ni.com/t5/LabVIEW/Retaining-Last-Value-without-a-While-loop/td-p/3359830
Thanks for all the help everybody!
SM
10-19-2016 11:06 AM
@Sman29 wrote:I eleminated the "last 5 messages" per your statement that it was just for debugging.
You need to keep most of it. The only thing you don't need is the indicator.
@Sman29 wrote:
I wired in the "current step" to the "Initialize Array". I am assuming that was where you meant my "message" to go?
That makes no sense at all! you need to initiailize the array exactly once at the start of the program with five empty strings. Do you know what "initialize array" actually does? did you look at the help?
@Sman29 wrote:I placed the "close file" inside the loop and the "create file" outside the loop.
Both belong outside the loop. One before and one after.
@Sman29 wrote:
Is it not just easier to read the last 5 messages from my file that I am already writing to? I am currently writing every message received to a file. ..
You never need to read from the file and it is not easier. storing five messages in memory and overwriting the entire file with the last five messages is significantly more efficient.
@Sman29 wrote:Raven attempted to help me read the last 5 messages from that file, but I couldn't get it to work either...
I am not surprised. Your last reply shows a complete lack of understanding of any of the issues at hand. You are well advised to do some lessons and tutorials before continuing. You don't just dive into the deep end of the pool without first learning how to swim. Good luck.