Advanced Scripting with Objects

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search

Introduction

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.

Some of the objects typically used within Solo Scripting include:

Data Management Objects

DATASET Objects

Create and manage data sets.

TCAST (type cast) objects

Convert variable data types and array sizes.

DataCache objects

Manages data caching for data historian applications such as Solo_Predictor trend chart application.

Modeling Objects

EVRIModel Objects

Build, apply, and manipulate models

EVRIScript objects

Automate tasks and invoke additional object types


Graphical User Interface Objects

EVRIGUI Objects

invoke and control Eigenvector Graphical User Interfaces

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, see EVRIGUI Objects) 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')

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)

EVRIScript Shortcut

A special shortcut exists when invoking an EVRIScript object. Instead of having to specify the name of the evriscript module name as a string input to a call to @evriscript, you can instead invoke the name of the module name directly as an object. So, instead of requesting a PCA evriscript object using:

obj = @evriscript('pca')

the object can be created by simply requesting a pca object:

obj = @pca

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 can use double-quotes:

obj.description = "my string here"

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. Note that currently, when calling some methods, the call needs to include an output assignment which will usually go back into the same object (see line 3 below). The "execute" method on the evriscript object is one example of this.

esobj = @evriscript('mncn');  #create evriscript object with mean center (mncn) mode
esobj.x = 'myfile.spc'        #assign property "x" using import of file
esobj = 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]);