Showing results 1 to 6 of 6

Thread: OnlineContainer differences between Onlinevariables and Onlinevariable removing and deleting

  1. #1
    mastr Gast

    Default OnlineContainer differences between Onlinevariables and Onlinevariable removing and deleting

    Hi @ all!

    Where are the differences between Onlinevariables and Onlinevariable.
    I just want to know if my understanding is correct.

    Onlinevariables hold all Objects of the type Onlinevariable, and so Onlinevariable is basically a subset of Onlinevariables.

    Onlinevariables.CreateOnlineVariables("Name_of_the_new_Onlinevariable_Container")
    => Create a new Container (Type: Onlinevariable) with Name "Name_of_the_new_Onlinevariable_Container"

    OnlineVariable.Add "Variable_Name" => inserts the Variable with the appropriate name
    OnlineVariable.Remove "Variable_Name" => removes a Variable with the appropriate name
    OnlineVariable.Define /Undefine => Activates/Deactivates the container

    Onlinevariables.DeleteOnlineVariables("Name_of_the_new_Onlinevariable_Container")
    => Deletes the container?

    My questions:

    What happens to the variables in the old container, if only the method Onlinevariables.DeleteOnlineVariables is called? Do I have to delete all variables before with OnlineVariable.Remove or are they automatically removed?

    How do I implement the eventhandling with OnlineContainers and how does it work?
    Is normal reading (mylocalVar = myzenonVar.Value ) and writing (myzenonVar.Value = 5) still possible even with variables in a container.

    Thanks for help in advance.

  2. #2
    Join Date
    28.07.2008
    Posts
    64

    Default Re: OnlineContainer differences between Onlinevariables and Onlinevariable removing and deleting

    Hallo mastr,

    OnlineVariable:
    The object OnlineVariable is a container for variables.

    The method Define of this object requests all variables, that are linked to that object. The same thing happens whenever a picture is opened in the Runtime. On initializing the variable or changing the value an event is executed, in which the changed variable can be edited as a parameter.
    This object should always be used, if one or more variable(s) are needed, that perhaps are not yet requested. As the request for the value of a variable takes most time, the performance here is increased, as you can be sure, that the values of the linked variables always are requested because of the method Define.

    Hint: For the event the object Visual Basic has to be defined with the attribute WithEvents.


    Using online variables always needs the following procedure:

    · Linking the online variable to variables of the control system. For each variable the method Add has to be executed with the unique name of the variable. Alternatively you can also use the method AddBulk. In this case a dynamic string array is created, that contains the variables

    Online Variables:
    This collection contains the single objects OnlineVariable. An online variable is an object, in which control system variables are linked, which on being initialized or changed execute a VBA event. In this VBA event user defined actions can be defined.

    The usage of online variables is recommended for the reading of variable values, as all variables linked to the online variable can be ordered with one action. This enhances the performance.

    Removes:
    Removes the linked variable strName from the object OnlineVariable.
    The parameter strName is the unique name of the variable to be removed. After removing the variable it is no longer monitored and the corresponding VBA event is no longer executed.

    If the variable with the name strName cannot be found in the list of linked variables, the value False is returned.

    DeleteOnlineVariables:
    This method deletes the object Online-Variable Objekt with the index or key strName from the collection. On deleting the object the variable is logged off the Runtime system and deleted from the collection.







    Quote Originally Posted by mastr View Post
    Hi @ all!

    Where are the differences between Onlinevariables and Onlinevariable.
    I just want to know if my understanding is correct.

    Onlinevariables hold all Objects of the type Onlinevariable, and so Onlinevariable is basically a subset of Onlinevariables.

    Onlinevariables.CreateOnlineVariables("Name_of_the_new_Onlinevariable_Container")
    => Create a new Container (Type: Onlinevariable) with Name "Name_of_the_new_Onlinevariable_Container"

    OnlineVariable.Add "Variable_Name" => inserts the Variable with the appropriate name
    OnlineVariable.Remove "Variable_Name" => removes a Variable with the appropriate name
    OnlineVariable.Define /Undefine => Activates/Deactivates the container

    Onlinevariables.DeleteOnlineVariables("Name_of_the_new_Onlinevariable_Container")
    => Deletes the container?

    My questions:

    What happens to the variables in the old container, if only the method Onlinevariables.DeleteOnlineVariables is called? Do I have to delete all variables before with OnlineVariable.Remove or are they automatically removed?

    How do I implement the eventhandling with OnlineContainers and how does it work?
    Is normal reading (mylocalVar = myzenonVar.Value ) and writing (myzenonVar.Value = 5) still possible even with variables in a container.

    Thanks for help in advance.

  3. #3
    Join Date
    28.07.2008
    Posts
    64

    Default Re: OnlineContainer differences between Onlinevariables and Onlinevariable removing and deleting

    This is a short sample how Onlinevariables and also the Eventhandler works:

    Dim WithEvents zOLV As OnlineVariable
    Const strOLV As String = "MyOnlineVariableContainer"
    
    'initialize event on runtime startup
    Private Sub Project_Active()
        'get object if already exists
        Set zOLV = thisProject.OnlineVariables.Item(strOLV)
        If zOLV Is Nothing Then
            'if not exitst, create a new OnlineVariable container
            Set zOLV = thisProject.OnlineVariables.CreateOnlineVariables(strOLV)
            'add variables to the container
            zOLV.Add "Variable1"
            zOLV.Add "Variable2"
            zOLV.Add "Variable3"
        End If
        'activate 'VariableChange' event
        zOLV.Define
    End Sub
    
    'event is fired when a variable value changes
    Private Sub zOLV_VariableChange(ByVal obVar As IVariable)
    Dim vValue As Variant
        vValue = obVar.Value
        'ignore error values (i.e. on startup)
        If IsError(vValue) Then Exit Sub
        Debug.Print obVar.Name & " = " & vValue
    End Sub
    
    'release objects on closing the runtime
    Private Sub Project_Inactive()
        'deactivate 'VariableChange' event
        If Not zOLV Is Nothing Then zOLV.Undefine
        Set zOLV = Nothing
    End Sub

    Quote Originally Posted by mastr View Post
    Hi @ all!

    Where are the differences between Onlinevariables and Onlinevariable.
    I just want to know if my understanding is correct.

    Onlinevariables hold all Objects of the type Onlinevariable, and so Onlinevariable is basically a subset of Onlinevariables.

    Onlinevariables.CreateOnlineVariables("Name_of_the_new_Onlinevariable_Container")
    => Create a new Container (Type: Onlinevariable) with Name "Name_of_the_new_Onlinevariable_Container"

    OnlineVariable.Add "Variable_Name" => inserts the Variable with the appropriate name
    OnlineVariable.Remove "Variable_Name" => removes a Variable with the appropriate name
    OnlineVariable.Define /Undefine => Activates/Deactivates the container

    Onlinevariables.DeleteOnlineVariables("Name_of_the_new_Onlinevariable_Container")
    => Deletes the container?

    My questions:

    What happens to the variables in the old container, if only the method Onlinevariables.DeleteOnlineVariables is called? Do I have to delete all variables before with OnlineVariable.Remove or are they automatically removed?

    How do I implement the eventhandling with OnlineContainers and how does it work?
    Is normal reading (mylocalVar = myzenonVar.Value ) and writing (myzenonVar.Value = 5) still possible even with variables in a container.

    Thanks for help in advance.

  4. #4
    mastr Gast

    Default AW: OnlineContainer differences between Onlinevariables and Onlinevariable removing and deleting

    Thanks for the answer.
    By the way your response speed is amazing

    Another thing: why do cannot edit my own entries?
    "Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten."

  5. #5
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    879

    Default Re: OnlineContainer differences between Onlinevariables and Onlinevariable removing and deleting


  6. #6
    mastr Gast

    Default AW: OnlineContainer differences between Onlinevariables and Onlinevariable removing and deleting

    Oh i already asked this question

    I don't get it done to edit my comment in the first 15 minutes, where is the edit button?
    Why is is there a time limit at all?
    I just want to edit the posts I created myself, nothing else more.

    Regardless, this forum is getting better and better

Similar Threads

  1. Working with 'OnlineVariables'
    By robertf in forum VBA
    Replies: 1
    Last Post: 16th April 2008, 16:26

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •