Advanced Scripting with Objects

From Eigenvector Research Documentation Wiki
Revision as of 10:21, 23 September 2010 by imported>Jeremy
Jump to navigation Jump to search

In addition to the standard objects and commands discussed in Solo Predictor Script Construction, various other objects can be created, modified, and manipulated through the Solo / Solo_Predictor scripting language. This document discusses those advanced objects and how to work with them.

Object Creation

The command to create an object in a Solo scripting language is based on providing a name for the object, followed by an equals sign, an @ symbol, the type of object to create and initial the object properties in parenthesis

objname = @objecttype(properties)

The properties required by an object vary from object to object. In all cases, numerical values can be supplied in square brackets [ ] and literal strings are supplied in single quotes ' '. Note that in this context, these quotes are NOT the same as an import command but pass the string included directly to the object. For example, an "EVRIGUI" object (which allows opening and accessing one of the Solo graphical user interfaces) is called with the name of the interface to create in single quotes:

obj = @evrigui('analysis')

Or in the creation of an evriscript object which requires the script module name to be passed:

obj = @evriscript('pls')

Finally, a name of another object (and or an object's properties) can be used in place of either a string or a numerical value. For example, creating a DataSet object to hold the predictions of a model would be done using:

obj = @dataset(model.predictions)

Property Manipulation

With any object, the properties of that object can be modified using standard import commands. For example, to assign the numerical values 3, 4 and 5 to a dataset object's "data" property, the following command would be used:

obj.data = '3,4,5'

Note the use of quotes (to indicate an import) and the comma-separated list of values.

To import a file into a property, simply provide the filename. For example, to import a file named "myfile.spc" into the "x" property of an evriscript object:

esobj = @evriscript('pls')    #create object
esobj.x = 'myfile.spc'        #import file an assign to x

Note that most import commands return dataset objects already.

To assign a literal string to a property, you must use the xml code:

obj.description = '<xml class="string">my string here</xml>'


Method Access

Some objects also have methods which can be accessed using standard "dot" notation on the object. An example is the EVRIScript object and its "execute" method:

esobj = @evriscript('mncn');  #create evriscript object with mean center (mncn) mode
esobj.x = 'myfile.spc'        #assign property "x" using import of file
esobj.execute;                #call method "execute"

Some methods also require inputs. In these cases, the calls are similar to the object creation commands where literal strings are passed in single quotes ' ' and numerical values in square brackets [ ]. As before, either of these can be replaced with a object name (of appropriate type)

An example of passing a string is calling the "setMethod" method of an evrigui object to the analysis method of the window:

egobj = @evrigui('analysis');   #create evrigui "Analysis" object
egobj.setMethod('pca');         #set evrigui object to 'pca' mode

Following that, you might call the "setComponents" method to assign the number of components. Note the use of square brackets to indicate the numeric value:

egobj.setComponents([3]);