LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Append only last 5 messages

Solved!
Go to solution
Solution
Accepted by topic author Sman29

Read the File as an array of strings.

Get the length of the array

Use Array Subset with length set to 5 and the intial position as the length of the array minus 5.

 

Did you look at Altenbach's code yet?  Here is is saved as LV13.

 

 

0 Kudos
Message 41 of 60
(1,176 Views)

Duplicated the post.

 

0 Kudos
Message 42 of 60
(1,176 Views)

Raven,

 

Thanks for fixing Altenbach's code. Works good by itself, but messes up everything when I put it in my code, due to the WHILE loop....

 

Regarding your suggestion, how do I get the length of an array?


Thanks,

SM-

0 Kudos
Message 43 of 60
(1,170 Views)

Raven,

 

So I attempted doing it your method. It only recorded message #'s 3-7 even though the last message that was stored on the logger that records all of the messages was message # 150... Any reason why this is, or is there something I am doing wrong (see attached screenshot)?

 

Thanks,

SM

0 Kudos
Message 44 of 60
(1,165 Views)

So I figured out why it was only storing messages 3-7. If I can just figure out how to get the length of the array I think it will work... Can anyone point me in the right direction to get the length of an array?


Thanks,

SM

0 Kudos
Message 45 of 60
(1,160 Views)

@Sman29 wrote:

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


Try this.

0 Kudos
Message 46 of 60
(1,159 Views)

Hi Alten,

 

Thanks for the reply. Raven already posted your VI as 2013 a few posts ago. It works good by itself, but unfortunately I cannot add any extra WHILE loops to my code or else it doesn't work right. Again as previously mentioned, I didn't inititially write this code, I'm just trying to modify it and it's very very fragile...

So right now I am attempting to do it using Ravens method, but I am not sure how to get the length of the array?


Thanks,

SM

0 Kudos
Message 47 of 60
(1,154 Views)

@Sman29 wrote:

 

Thanks for fixing Altenbach's code. Works good by itself, but messes up everything when I put it in my code, due to the WHILE loop....


You can't just drop that code inside your own code, you need to understand it and the apply the same principles.

It shows two things:

  • How to keep a history of the last five entries
  • How to write it to a flle whenever it changes

Do you fully understand my code?

 

To intergrate the ideas into your existing program, you would eliminate my while loop and place the shift registers into your own outer while loop.

 

Can you attach the code where it "messes everything up" so we can get a better understanding what you are doing.

0 Kudos
Message 48 of 60
(1,152 Views)

@Sman29 wrote:

So I figured out why it was only storing messages 3-7. If I can just figure out how to get the length of the array I think it will work... Can anyone point me in the right direction to get the length of an array?


Thanks,

SM


Go to the Array palette.  There is a function called Array Size.  Your one set of code won't work because you have a race condition between the size indicator (which is using the Array Size functon you can't find.), and the local variable.  As well as a race condition between writing to a file and reading from it.  You have no control over whether the reads or writes happen first.

 

Have you taken LabVIEW tutorials?
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

 I would also recommend taking some time to browse around the palettes while you have Context Help turned on to familiarize yourself with the varioius functions.

Message 49 of 60
(1,144 Views)

"You can't just drop that code inside your own code, you need to understand it and the apply the same principles.

It shows two things:

  • How to keep a history of the last five entries
  • How to write it to a flle whenever it changes

Do you fully understand my code?"

 

I have to say, no I do not fully understand your code.. I'm still an amateur at LV...

 

"To intergrate the ideas into your existing program, you would eliminate my while loop and place the shift registers into your own outer while loop."

I can't really do it that way because the data coming into my WHILE loop is a cluster, and it gets split into the arrays in a case structure...

 

 

"Can you attach the code where it "messes everything up" so we can get a better understanding what you are doing."

 

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.


Thanks,
SM

0 Kudos
Message 50 of 60
(1,137 Views)