Showing results 1 to 2 of 2

Thread: Using Variables form Zenon in C#

  1. #1
    Join Date
    29.01.2016
    Posts
    19

    Frage Using Variables form Zenon in C#

    Hello.

    How can I read and write to the Zenon variables?

    I tryied it following way:

    zenOn.IVariable Registr;
    Registr.set_Value(0, valueInC#)

    Error: Use of unassigned local variable Registr

    Thank you

  2. #2
    Join Date
    08.08.2013
    Posts
    44

    Default Re: Using Variables form Zenon in C#

    Hi DavidMarek,

    you did not define you local variable, so therefore you tried to access a null reference which is not possible.
    A proper way can look like this:
            public void Macro_GetSetValue()
            {
                zenOn.IVariable myVar = this.Variables().Item("myzenonVariable");
                //check if the variable is advised to read the value
                if (myVar.IsOnline() == true)
                {
                    myVar.get_Value(0);
                }
    
                //set a value to the variable
                myVar.set_Value(0, 10);
            }

    Further Information can be found in the zenon help under the following chapter:
    Manual -> Programming interfaces -> Objectmodel -> Variable


    BR
    Christian

Similar Threads

  1. zenon logic doesn't communicate with external variables in zenon
    By mashjj in forum straton / zenon Logic
    Replies: 6
    Last Post: 27th February 2015, 13:10
  2. Re: zenon logic doesn't communicate with external variables in zenon
    By anjali.gk.nair@gmail.com in forum straton / zenon Logic
    Replies: 2
    Last Post: 22nd August 2014, 10:51
  3. Replies: 1
    Last Post: 31st January 2011, 15:23
  4. Replies: 1
    Last Post: 3rd August 2010, 10:02
  5. Replies: 0
    Last Post: 12th May 2010, 09:58

Posting Rules

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