Showing results 1 to 3 of 3

Thread: How to get a current value of variable that not displayed in the runtime.

  1. #1
    Join Date
    16.12.2010
    Posts
    31

    Default How to get a current value of variable that not displayed in the runtime.

    Hi, All

    i am using a zenon 7.10.

    I want to get a current value of variable via vba.

    I found it in the manual.

    ******
    var_val = thisProject.Variables.Item(i).Value
    ******

    It can get a value of variable when display in the runtime (screen).

    but, no data when the variable is not displayed in the runtime.

    So, I need " how to get a current value of variable that not displayed in the runtime via VBA ".


  2. #2
    Join Date
    29.07.2007
    Location
    Germany
    Posts
    191

    Default AW: How to get a current value of variable that not displayed in the runtime.

    Hi,

    you will find more then 'var_val = thisProject.Variables.Item(i).Value' in the manual.
    Direct VBA read access on variables is only possible if the variable has been registered in the driver (advised) and if it has a value, i.e. if IsOnline() is true . Simple spontaneous queries (requests) are no longer possible.
    The following functions of the “Variable” object return an error if this is not the case:

    Value
    StatusValue
    StatusExtValue
    StatusString
    LastUpdateTime
    LastUpdateTimeMilliSeconds
    This means that existing projects will no longer run in the Runtime after the conversion, as the functions mentioned above will fail.

    Possible solutions:

    Define an online container for all affected variable accesses.
    Advantage: The variables will only be requested if you really need them.
    Disadvantage: Increased programming effort.
    Set the option “DDE active” in the group “Additional settings” of the variable properties for all affected variables.
    Advantage: Easy to perform.
    Disadvantage: The driver continuously requests all variables.


    So hope the help helps

    HP
    string zenon = "7.60 Build52515 / 8.00 Build52082";
    string Windows = "7 / 10 / 2012R2";
    string VMware = "Workstation / VMware ESXi";

  3. #3
    Join Date
    16.12.2010
    Posts
    31

    Default Re: How to get a current value of variable that not displayed in the runtime.

    Thanks for your kindly reply.

    I tried what you suggested.

    1. Set the option “DDE active” in the group “Additional settings” of the variable properties for all affected variables.
    => does not work.
    2. 
    Define an online container for all affected variable accesses.
    => 

    I tried it as follow code.

    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

    but, it can get a value when value change.

    I need a current value anytime via vba.

    one more question, while trying,

    it can get a value when display the runtime.
    which means, 
    it work when  "" zVariables.IsOnline = 1 "" I think.

    so, I did

    Dim zVariables As Variable

    Set zVariables = thisProject.Variables.ITEM("Test_Val_15")

    zVariables.IsOnline = 1

    zVariables.IsOnline = "1"

    zVariables.IsOnline = True

    but, it does not work.
    is it possible to make the value "true" to work ??

    Thanks




Similar Threads

  1. Alarm message compare with current Date
    By navaneet in forum zenon Supervisor
    Replies: 6
    Last Post: 17th November 2014, 13:24
  2. Sending current values via e-mail
    By tihomir in forum zenon Supervisor
    Replies: 3
    Last Post: 17th February 2014, 09:30
  3. Current user in header section of the project
    By yolovs in forum zenon Supervisor
    Replies: 2
    Last Post: 31st July 2013, 10:02
  4. Variable set is not variable being displayed
    By smurfy in forum zenon Supervisor
    Replies: 5
    Last Post: 22nd February 2012, 04:00
  5. zenOn is not displayed on two monitors
    By markclemens in forum zenon Supervisor
    Replies: 2
    Last Post: 8th November 2007, 14:03

Posting Rules

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