aarloe

Circular referencing Trend TimeRangeChange event?

Discussion created by aarloe Employee on Jul 30, 2009
Latest reply on Nov 19, 2012 by andreas

Hello, first time poster to the vCampus, (relatively) new VBA Scriptor in PB. I was wondering if it might be possible to expand the TimeRangeChange demo that appears in the Advanced Processbook Scripting CBT to include updating the time ranges for ALL trends on a display whenever ANY trend's time range is updated? I've tried this on my own with say, 3 trends, and whenever I zoom in on one trend, PB crashes. It kind of works when using only 2 trends, but is still noticebly slower than just one trend.

For example, the code in the demo shows this:

Private Sub Trend_TimeRangeChange(ByVal StartTime As String, ByVal EndTime As String)
    Trend2.SetTimeRange StartTime, EndTime
End Sub

 

which updates the time range of the second trend on the display whenever the first trend's time range is changed (i.e. by zooming anywhere). What I'd like to do is this:

Private Sub Trend1_TimeRangeChange(ByVal StartTime As String, ByVal EndTime As String)
    Trend2.SetTimeRange StartTime, EndTime
    Trend3.SetTimeRange StartTime, EndTime
End Sub

Private Sub Trend2_TimeRangeChange(ByVal StartTime As String, ByVal EndTime As String)
    Trend1.SetTimeRange StartTime, EndTime
    Trend3.SetTimeRange StartTime, EndTime
End Sub

Private Sub Trend3_TimeRangeChange(ByVal StartTime As String, ByVal EndTime As String)
    Trend1.SetTimeRange StartTime, EndTime
    Trend2.SetTimeRange StartTime, EndTime
End Sub

But I think I'm just creating an infinite loop, such that whenever I zoom in on Trend1, Trend2 & Trend3's time ranges are changed, which causes them to execute the code, which changes the time range of Trend1, and the cycle repeats indefinately until I force quit PB.

 

Any suggestions?

Outcomes