1 Reply Latest reply on May 7, 2012 2:08 PM by andreas

    ProcessBook - Issue controlling add/show traces in a trend

    ericL

      Hi, Right now, I have a mechanism to open a display, show no traces in a trend. Now, as I click on a value, it adds/shows the trace of the element relative attribute on the trend. If I click again on it, it gives me the following error "Run Time Error 8327, The specified tag already exists" In essence, I am not putting a condition such as: "If tag is not showing, then show it" I am not sure how the syntax works. Any help would be much appreciated. Thank you,

       

      Code example:

       
      Private Sub ShowTrace(attr As String) 
         Trend3.AddTrace (attr) 
         Trend3.ShowTrace = True 
      End Sub 
      
      Private Sub Value59_Click(ByVal lvarX As Long, ByVal lvarY As Long) 
         Dim attr As String 
         attr = Value59.GetTagName(1) 
         Call ShowTrace(PDMS) 
      End Sub
      

       

        • Re: ProcessBook - Issue controlling add/show traces in a trend
          andreas

          Eric,

           

          the easiest way would be as simple as this:

           
          Private Sub ShowTrace(attr As String)
              On Error Resume Next
              Trend3.AddTrace (attr)
              Trend3.ShowTrace = True
          End Sub
          

           

           

          what concerns me more is you second sub - as I don't think you want to write 59 identical subs, how about this aproach:

          • you act on the selection change event (because clicking on the value symbol changes the selection.
          • you check that there is only one selected symbol
          • you check that this selected symbol is a value

          as below:

           
          Private Sub Display_SelectionChange()
              If Me.SelectedSymbols.Count = 1 Then
                  If Me.SelectedSymbols.Item(1).Type = pbSymbolValue Then
                      Dim MySymbol As Value
                      Set MySymbol = SelectedSymbols.Item(1)
                      Dim attr As String
                      attr = MySymbol.GetTagName(1)
                      Call ShowTrace(attr)
                  End If
              End If
          End Sub