Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 5 Sequences & Scripting > 5.20 Object Oriented Programming

5.20.9 Getting a Reference to Ourselves

Scroll Prev Top Next More

If you want to access a reference to an object from within the member function of an object you can use the this keyword.  So for example:

 

class CMyClass
   function getMe()
      return(this)
   endfunction
endclass

global x = new(CMyClass)
global y = x.getMe()

The above will make x and y reference the same object.  Of course we could just do y=x in the last line, but...

Beta: (this is still under development, may not work on all objects):

This can also be used to get references to internal DAQFactory objects.  For example:

 

global chanRef = myChannel.this
global compRef = component.VarValueComponent.this

You can then use these references much like you'd use the internal object.  The exception is things that return values if you reference just the object like Channels, which, if you simply ask for a channel by name, will return the value stored in the channel.  In this case, in order to access the value of the channel you have to use the value keyword in the object.  For example:

 

? myChannel[0]  // prints the most recent value of myChannel
myChannel.addValue(3) // adds the value 3 to the history of myChannel
global chanRef = myChannel.this
? chanRef  // prints "Object(s)" 
? chanRef.Value  // prints the most recent value of myChannel
chanRef.addValue(3)   // adds the value 3 to the history of myChannel