LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Darren's Weekly Nugget 06/28/2010

If you have a string indicator that displays continuously updating data, there is an easy way to keep the indicator scrolled to the latest data:

 

17593i4102A5D340924B5D

 

If you wire a value of +Inf to the Text.ScrollPos property of a string indicator, it will always scroll to the very end of the data displayed within the indicator.

Message 1 of 23
(9,032 Views)

Great tip Darren. Smiley Happy  I've been doing it the hard way.  Counting lines and setting the position to display the last few lines.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 23
(9,009 Views)

Oh Darren, you've got a race condition there..... Smiley Tongue

Message 3 of 23
(8,990 Views)

Hi Darren,

 

any reasonable big number would do the trick - even an U32 (like 2^32-1) to avoid the coercion dot Smiley Wink

But that +Inf takes less BD space...

Best regards,
GerdW


using LV2016/2019/2020 on Win8.1/10+cRIO
0 Kudos
Message 4 of 23
(8,971 Views)

Just add a U32 conversion and it's coercion free and still pretty and small. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
Message 5 of 23
(8,901 Views)

@Yamaeda wrote:

Just add a U32 conversion and it's coercion free and still pretty and small. 🙂

/Y


Or the best solution yet... let Constant Folding run it's course. I remember one time a surprising benchmark from altenbach that proved in some cases coercion dots gave better run-time performance than explicit conversions.

 

And Darren, great nugget, thanks, as usual!

0 Kudos
Message 6 of 23
(8,760 Views)

Good one Darren. I think I picked that one up on a forum some time ago.

 

I wish I could figure out a way to do this only if the scroll bar is at the bottom. Right now if you try to scroll up to see something from earlier, you lose it as soon as the next bit of data comes in. I've wished for this when watching a 1Hz GPS stream come in. I want to go back and look at what happened a few seconds ago. Of course you could do something where you have a control on the FP to turn on/off autoscrolling, but it would be more complicated to make the autoscrolling depend on whether you were clicking on the scroll bar, or whether the scrollbar was scrolled up. Hmm... it would be nice if autoscroll could be a built-in option for text boxes to automagically do all this.

-Randy
-=--=-=-=-=-=-=-
Nothing like a good dose of LabVIEW to cure what ails ya'.
0 Kudos
Message 7 of 23
(8,723 Views)

Hi Randy,

 

Here's a quick solution for your use case.  If the user manually scrolls the string, it turns off the auto scrolling.  If he then clicks the "Resume Autoscroll" button, it starts auto scrolling again.  This is the best I can do with what we have...we would need a "Maximum Scroll Position" property to be able to have it automatically start auto scrolling again when you scroll to the bottom.

Message 8 of 23
(8,714 Views)

Thanks Darren! Your code there is more useful than you may have realized. We actually (sort of) do have a Maximum Scroll Position Property, at least at the instant when we set the Scroll Position to +∞. My attached modification to your code seems to work. I think some additional logic would be needed to handle would be the case where the length of the string was shortened--I think you could get stuck with AutoScroll off.

 

If I'm missing something, please feel free to point it out. Thanks!

-Randy
-=--=-=-=-=-=-=-
Nothing like a good dose of LabVIEW to cure what ails ya'.
0 Kudos
Message 9 of 23
(8,627 Views)

Yeah, when I first tried to solve this, I made that assumption too.  But where it breaks down is that the max scroll position stored becomes stale once the string scrolls to more lines.  You can see this by doing the following with your VI:

 

  1. Run the VI.
  2. As soon as the scrollbar appears (i.e. after 5 lines of string are created), scroll to the top.
  3. Wait a while, like maybe 10 seconds...enough time for several more lines to have been created.
  4. Start clicking the down arrow of the scrollbar to scroll down incrementally.  After only one or two clicks, your string will scroll all the way back to the bottom and start auto scrolling again, even though you were nowhere near the bottom of the string.

The reason it does this is that the max scroll position you stored (probably 5 or 6) is an old value...after 10 seconds, the string may have dozens of lines.  So when you start scrolling down again, once you go past 5 or 6 lines, you exceed the old stored max scroll position value, and it starts auto scrolling again.

 

So again, the only solution I see for this (other than making your own enable scrolling button like I did) is to have a property you can read on the string that gives you the current maximum scroll position.

0 Kudos
Message 10 of 23
(8,577 Views)