I'm answering Karl's VBA question to the list because it brings up other
questions I have been meaning to ask.
I presently use S Plus 2000 and use VBA to create permanent objects with
out any trouble. The short answer is use the assign function. In S Plus
2000 there is a worked example the Automation chapter of online
Programmer's Guide. Files are in samples/oleauto/vba in the S Plus program
folder. There are additional examples in chapter 9 of S Programming. I
haven't tried it in version 6 yet and would be interested in knowing your
success.
Here is a short summary of how I do it.
* create a function in S Plus, make an argument for each input
* the function and argument names need to be valid in S Plus AND VBA so
use RespDF instead of resp.df
* everything is sent over as a data.frame (regardless of VBA definition)
so you may want to unlist simpler inputs
* register the S Plus function
AutoSum <- function(input1, input2){
output <- input1 + input2
assign("out", output, where = 1)
}
register.ole.object("AutoSum")
In VBA get the inputs ready (here named pInput1 and pInput2) and put the
following code in you sub
Dim AutoSum As Object
Set AutoSum = CreateObject("S-Plus.AutoSum")
AutoSum.input2 = pInput1
AutoSum.input1 = pInput2
AutoSum.Run
Set AutoSum = Nothing
This should create the object "out" as a permanent object.
My questions:
* Is there a way to send object types other than dataframes?, specifically
I am interested in sending 3 or 4 dimensional arrays. The objects exist in
both languages so it seems reasonable to be able to send them.
* Is there an advantage to using ".BeginTransaction" /
".CommitTransaction" over the way outlined above? There are a lot of
examples but they aren't clear why it is needed.
Thanks, Karen
Hi,
I've been playing around with S-Plus 6 (Windows 2000) using Visual Basic as
an automation client to read and write data.frame objects in S-Plus. I can
read them fine, but those that are written to S-Plus disappear when the
Visual Basic automation client application exits.
While I can see that this would be the intended behaviour for an automation
client object is a way to make the created data.frame objects permanent in
S-plus?
Thanks for any advice
Karl
-------------------------------------------------------------------------------------------------------------------------------
Karl Nissen
Programmer/System administrator Phone: (+61 2)
6125 4613
School of Resources, Environment and Society Fax: (+61 2)
6125 3770
The Australian National University e-mail:
karl.nissen@anu.edu.au
-------------------------------------------------------------------------------------------------------------------------------
|