SET DCOM

From STX Wiki
Jump to navigationJump to search
DCOM Item
NEW SET

The DCOM shell item supports the following SET commands:

INVOKEMETHOD

SET $#dcomItem INVOKEMETHOD MethodName [param1 param2paramn]

Invoke a DCOM object method.

MethodName the name of the remote method
param1paramn parameters for the method MethodName

Communicating with R

There is a number of DCOM commands specific to the R language and environment for statistical computing and graphics. You can find more details on their homepage: http://www.r-project.org/

STx can communicate with R using the DCOM interface implemented in STx as a shell item (DCOM).

Note that if you are running R 2.2 or greater, you will need the 2.0 R (D)COM server.

SETDATA

SET $#dcomItem SETDATA R_var_name string /Constant
SET $#dcomItem SETDATA R_var_name variable [/Variable]
SET $#dcomItem SETDATA R_var_name table [index count][/Variable]

Create a variable and set its value and type, in an R workspace. SETDATA is a special method implemented for use with the R DCOM server. Currently the following types of variables are supported: string, number(float) and matrix. The maximum number of dimensions for a matrix is currently two.

R_var_name The name of the variable to be created in the R workspace.
string In conjunction with the option /Constant the string to assign to the variable R_var_name. If string is a numerical expression, the numerical value is assigned.
variable The STx variable name, which contains the value to be assigned to R_var_name (the option /Variable can be used, but is optional).
table The name of an STx table containing the values to be assigned to R_var_name. Note that by default only the column 0 is sent.
index If a table is passed, the index of the first field to use in the table. The default is 0.
count If a table is passed, the number of fields to read (starting from index). Note that all fields from index to count-1 must be numerical fields. The default is 1.

Example

///////////////////////////////////////////////////////////////////////////////
//
//  Macro:          DCOMSetData
//  Description:    Send a string to the statistical package R and tell R to
//                  edit the string (i.e. open a text file).
//  Usage:          DCOMSetData
//  Return:         0
//  Author:         Jonnie White
//  History:        2005-04-26
//                  
///////////////////////////////////////////////////////////////////////////////
[macro dcomsetdata]

    #dcom := $(new DCOM * 'StatConnectorSrv.StatConnector')
    if '$#dcom' == '*' em -1 ; Error creating R DCOM server

    $#dcom INVOKEMETHOD Init R
    if '$rc' > 0 em  $rc ; Failed to invoke Init R method

    #myStr := 'The quick brown fox jumps over the lazy dog'

    $#dcom SETDATA myStr #myStr
    if '$rc' > 0 em $rc ; failed to setdata the R variable 'myStr'

    $#dcom INVOKEMETHOD EvaluateNoReturn ' edit(myStr)'
    if '$rc' > 0 em $rc ; failed to evaluate 'edit(myStr)'

    $#DCOM SETDATA myStr '$#myStr' /Constant
    if '$rc' > 0 em $rc ; failed to setdata myStr #myStr

    $#dcom INVOKEMETHOD EvaluateNoReturn 'edit(myStr)'
    if '$rc' > 0 em $rc ; failed to evaluate 'edit(myStr)'

    delete $#dcom
exit 1 int 0

GETDATA

SET $#dcomItem GETDATA R_var_name variable
SET $#dcomItem GETDATA R_var_name table [index{0} count{1}]
SET $#dcomItem GETDATA R_var_name value

Get the value of a variable in an R workspace. GETDATA is a special method implemented for use with the R DCOM server.

R_var_name The name of a variable that exists in an R workspace.
variable The name of an STx variable that will be assigned the value of R_var_name. The variable can receive string or number data.
table The name of an STx table to receive values from R_var_name. Note that a table can only receive vector or matrix data.
index The zero-based index of the table field to receive the first column of R_var_name.
count The number of fields into which the data from R_var_name should be copied.
value The name of an STx value item that will be assigned the value of R_var_name. The value item can receive string, number, vector or matrix data.

Navigation menu

Personal tools