LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Append only last 5 messages

Solved!
Go to solution
Solution
Accepted by Sman29

Try something like this...

Message 31 of 60
(2,038 Views)

Alten,

 

I am using LV 2013, could you repost that code with a LV 2013 so that I can see it?


Thanks,
SM

0 Kudos
Message 32 of 60
(2,009 Views)

Apok,

 

I tried doing what you said and it will still only take just the last message, not the last 5... I also tried doing that in a FOR loop, but I was still getting the same errors (Scalar to array type issue). Any other ideas? Or am I just doing it wrong (see attached)?

 

Thanks,

SM

0 Kudos
Message 33 of 60
(2,007 Views)

You are using Index Array and getting out just a single row.

 

Throwing a For Loop with N=5 around it "just because" doesn't make any sense.  The reason you get a wiring error is because  you are now auto-indexing on each element of the 1-D array turning them into scalar strings.

0 Kudos
Message 34 of 60
(2,004 Views)

Raven,

 

Oh ok, I think I understand. However, with or without a FOR loop, I still can't get the last 5 messages stored...


Thanks,

SM

0 Kudos
Message 35 of 60
(2,002 Views)

Does each message consist of 1 line of that 2-D array of strings?

 

If so, you don't wnat index array to get one line.  You want to use Array Subset to get X lines.

0 Kudos
Message 36 of 60
(1,997 Views)

Raven,

 

This is what the strings look like:

[ABB Robot] [Abb Motion] [Move Home] [TRUE] [Completed] [0] [1]
[ABB Robot] [Abb Motion] [Move Target1] [TRUE] [Completed] [0] [2]
[ABB Robot] [Abb Motion] [Move Target2] [TRUE] [Active] [0] [3]
[ABB Robot] [Abb Motion] [Move Target3] [TRUE] [Pending] [0] [4]...

These individual lines come in one at a time. Not sure if that answered your question?

Also, I tried it with Array Subset and it didn't really work either. Maybe I put it in the wrong place (see attached)? I also tried the Array Subset with Delete From Array and it didn't work either.. It won't even record a single line..

 

Thanks,

SM

 

Thanks,

SM

Download All
0 Kudos
Message 37 of 60
(1,994 Views)

Here's another thought, not sure how to do it or if it would even work... So currently I have a method to store all the messages received to a spreadsheet file. What if I could just read from that file, and only get the most recent 5 messages? Like have something to increment every time a message is received, and that incremement is tied to the start of read offeset or whatever of the Read From Spreadsheet VI? Would something like that work? And if so, how would I go about doing that?

 

Thanks,

SM

0 Kudos
Message 38 of 60
(1,992 Views)

@Sman29 wrote:

Here's another thought, not sure how to do it or if it would even work... So currently I have a method to store all the messages received to a spreadsheet file. What if I could just read from that file, and only get the most recent 5 messages? Like have something to increment every time a message is received, and that incremement is tied to the start of read offeset or whatever of the Read From Spreadsheet VI? Would something like that work? And if so, how would I go about doing that?

 

Thanks,

SM



You can do that also.  I think the problem is that you haven't clearly defined in your own mind as to how things work and how you can make them work for your needs.  It feels like this message thread is coming back in a circle.

 

So what if things come in one at a time, which is how I'd expect things to be.  Every time something is completed, just put that new message at the end of the array using Build Array and store the array in a shift register.  If you want just the last 5, than use Array Subset to get the last 5.  You can certainly store all of that info in a file and just read the end.  How much data are you actually talking about here?

 

In your original message, you said you did not want to store all the data, only the last 5.  Now you say you are storing all of the data to a file.  In message 4 you said "The bigger picture is that the text file will eventually be containing thousands of lines due to the number of messages being sent/written. I don't want to store thousands of lines, only the last few."  Thousands of lines in a data file is not that much.  It is not that much to store thousands of lines in memory within the VI as it is running.

 

Are you changing your requirements for your VI?  Going back do my first paragraph, you need to clearly define what you want.  Until you do that, you seem to be just chasing your tail.

0 Kudos
Message 39 of 60
(1,987 Views)

Raven,

 

Apologies for the confusion... I will try to answer your questions one at a time:

 

"So what if things come in one at a time, which is how I'd expect things to be.  Every time something is completed, just put that new message at the end of the array using Build Array and store the array in a shift register.  If you want just the last 5, than use Array Subset to get the last 5.  You can certainly store all of that info in a file and just read the end.  How much data are you actually talking about here?"

 

Just talking about thousands of lines in a text file. They are indeed coming in one line at a time. How can I do like what you said: "If you want just the last 5, than use Array Subset to get the last 5"? I tried it already and it wouldn't store anything...

 

"In your original message, you said you did not want to store all the data, only the last 5.  Now you say you are storing all of the data to a file.  In message 4 you said "The bigger picture is that the text file will eventually be containing thousands of lines due to the number of messages being sent/written. I don't want to store thousands of lines, only the last few."  Thousands of lines in a data file is not that much.  It is not that much to store thousands of lines in memory within the VI as it is running."

 

Yes I said I only wanted the last 5. I was already storing all the data since it was so simple to do, and it was better than nothing. But I was really only wanting the last 5 lines. Thousands of lines in a data file is a lot when you are having to scroll to the bottom everytime just to see the last 5 messages.

 

"Are you changing your requirements for your VI?  Going back do my first paragraph, you need to clearly define what you want.  Until you do that, you seem to be just chasing your tail."

 

 

Not changing the requirements. Still need to have just some way to store and display the last 5 messages received. I think some people were confused on what I was asking, but perhaps this will clear it up: I am receiving a 1-D array of strings, one line at a time. I am wanting to store the last 5 lines received, as well as display them. But one thing at a time, so the storing of the last 5 lines is what needs to be addressed first.


Hope that helps clear things up...


Thanks for all the help and patience,

SM

0 Kudos
Message 40 of 60
(1,985 Views)