Add_method()

Associate an existing Open GENIE procedure with a workspace class for object oriented programming.

ADD_METHOD class=String procedure=String [method=String] Associate an existing procedure with a class method.

example:

	# Add a focus method to a Triple axis workspace class
	>> Add_method(class="Triple_axis", "Multiply_angles", "focus")
	>> ta_spec = Create("Triple_axis")	# create a spectrum
	>> ta_spec.focus(x, y)			# calls multiply_angles

Note: by default, method is given the same name as the procedure

Add_method

This is the way in which Open GENIE allows the addition of methods to workspace classes.  Once added, methods are invoked using syntax similar to that used for accessing a workspace field but with a (possibly empty) parameter list following the field name.

Rather than have a totally different way of creating a method, Open GENIE uses the standard PROCEDURE definition mechanism.  A procedure is then "attached" to the class where is is needed using Add_method().  The one significant difference is that a local varaible _SELF is always available in any procedure invoked as a method (it is undefined if the procedure was not invoked as a method).  So, for example, the procedure definition of "Mutliply_angles" shown in the example above would be structured as follows.

	PROCEDURE Multiply_angles
	PARAMETERS X=Real  Y=Real	# check type of object
		...	# eg _Self.f1 refers to field "f1" in the calling object
	ENDPROCEDURE

anywhere within the body of the procedure, the variable _SELF can be accessed and refers to the object against which the original call was made.

Parameters:

Class (String)

The name of the class to which to add the specified method.  From this point on, any subclasses of this class will also run this method automatically if it is called on them.

Procedure (String)

The name of an Open GENIE procedure written as above with one extra parameter of the correct object type.

Method (String) [ default = Procedure ]

A name for the method which if left blank will be given the same name as the procedure.   There is no reason why the same procedure may not be assigned to more than one method.