Programmer Guide/Shell Items/DCOM/SET DCOM: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (Text replace - "S_TOOLS-STx" to "{{STX}}")
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
==SET DCOM==


The following <code>SET</code> commands are understood by the <code>DCOM</code> shell item:
The [[Programmer_Guide/Shell_Items/DCOM|DCOM]] shell item supports the following <code>SET</code> commands:


====INVOKEMETHOD====
==INVOKEMETHOD==


<code>SET $#dcomItem INVOKEMETHOD <var>MethodName</var> [<var>param_1</var> <var>param_2</var> .... <var>param_n</var>]</code>
SET $#dcomItem INVOKEMETHOD <var>MethodName</var> [<var>param<sub>1</sub></var> <var>param<sub>2</sub></var> &hellip; <var>param<sub>n</sub></var>]


Invoke a DCOM object method.
Invoke a DCOM object method.
Line 12: Line 11:
{|
{|
|-
|-
|MethodName
| <var>MethodName</var>
|the name of the remote method
| the name of the remote method
|-
|-
|param_1 ... <var>param_n</var>
| param<sub>1</sub> &hellip; <var>param<sub>n</sub></var>
|parameters for the method MethodName
| parameters for the method <var>MethodName</var>
|}
|}




==SETDATA==


====SETDATA====
The following commands are specific to the [http://www.r-project.org/|R] statistical program.


The following commands are specific to the R statistical program.<code>SET $#dcomItem SETDATA <var>R_var_name string</var> /Constant</code>
SET $#dcomItem SETDATA <var>R_var_name string</var> /Constant
 
SET $#dcomItem SETDATA <var>R_var_name variable</var> [/Variable]
<code>SET $#dcomItem SETDATA <var>R_var_name variable</var> [/Variable]</code>
SET $#dcomItem SETDATA <var>R_var_name table</var> [<var>index</var> <var>count</var>][/Variable]
 
<code>SET $#dcomItem SETDATA <var>R_var_name table</var> [<var>index</var> <var>count</var>][/Variable]</code>


Create a variable and set its value and type, in an R workspace. <code>SETDATA</code> 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.
Create a variable and set its value and type, in an R workspace. <code>SETDATA</code> 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.


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


'''Example'''
'''Example'''
Line 94: Line 89:
exit 1 int 0
exit 1 int 0
</pre>
</pre>
====GETDATA====


The following commands are specific to the R statistical program.<code>SET $#dcomItem GETDATA <var>R_var_name variable</var></code>
==GETDATA==


<code>SET $#dcomItem GETDATA <var>R_var_name table</var> [<var>index</var>{0} <var>count</var>{1}]</code>
The following commands are specific to the R statistical program.


<code>SET $#dcomItem GETDATA <var>R_var_name value</var></code>
SET $#dcomItem GETDATA <var>R_var_name variable</var>
SET $#dcomItem GETDATA <var>R_var_name table</var> [<var>index</var>{0} <var>count</var>{1}]
SET $#dcomItem GETDATA <var>R_var_name value</var>


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


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


====R====
====R====

Revision as of 13:59, 31 October 2012


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


SETDATA

The following commands are specific to the [1] statistical program.

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

The following commands are specific to the R statistical program.

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.

R

R is a 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.

Navigation menu

Personal tools