Recent

Author Topic: Connection with R-Project  (Read 9853 times)

pedropadel

  • Newbie
  • Posts: 5
Connection with R-Project
« on: February 15, 2013, 11:07:13 pm »
Hello

I'm trying to translate the following application Delphi to Lazarus but I get errors with the following libraries: OleCtrls, OleServer, StdCtrls, OleServer, StdVCL

The application is for connecting with R-Project (statistical software). It is this one:

http://www.menne-biomed.de/download/RDcomDelphi.zip

What could be the solution? Is there any example in connection R-Project from Lazarus.

I would be very grateful if you could help me.

Thank you very much!

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Connection with R-Project
« Reply #1 on: February 15, 2013, 11:14:32 pm »
This is a very interesting project. Do you have any additional documentation at hand? The web site http://www.menne-biomed.de doesn't seem to be too informative with regard to this issue.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

pedropadel

  • Newbie
  • Posts: 5
Re: Connection with R-Project
« Reply #2 on: February 16, 2013, 03:30:29 pm »
No, I have only this code Delphi

Also I have another example, but using a DLL in VB.NET.

Interop.STATCONNECTORCLNTLib.dll
Interop.StatConnectorCommonLib.dll
Interop.STATCONNECTORSRVLib.dll


Code: [Select]
Imports STATCONNECTORCLNTLib
Imports StatConnectorCommonLib
Imports STATCONNECTORSRVLib

Dim sc1 As StatConnector = New STATCONNECTORSRVLib.StatConnectorClass()
sc1 = New STATCONNECTORSRVLib.StatConnectorClass()
sc1.Init("R")
sc1.Evaluate("1+1")


How are DLLs with Lazarus? Perhaps that could be a solution ...

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Connection with R-Project
« Reply #3 on: February 16, 2013, 04:29:01 pm »
The code provided by Dieter Menne is interesting, but not versatile. It uses COM interfaces and DLLs making the software restricted to Windows.

A cross-platform solution would be preferable, e.g. by using embedded shell calls.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Connection with R-Project
« Reply #4 on: February 16, 2013, 04:50:31 pm »
Quote
How are DLLs with Lazarus? Perhaps that could be a solution ...
How what? Create or link? Well, in any case, consult the documentation: http://www.freepascal.org/docs-html/prog/progch12.html

pedropadel

  • Newbie
  • Posts: 5
Re: Connection with R-Project
« Reply #5 on: February 16, 2013, 07:21:34 pm »
Quote
How are DLLs with Lazarus? Perhaps that could be a solution ...
How what? Create or link? Well, in any case, consult the documentation: http://www.freepascal.org/docs-html/prog/progch12.html

Link. How to link a DLL?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Connection with R-Project
« Reply #6 on: February 17, 2013, 12:04:44 am »
Quote
Link. How to link a DLL?
You have must declare the function(s) you'd like to call from the dll using external declaration AND call it in your program. The DLL will then be automatically linked.

pedropadel

  • Newbie
  • Posts: 5
Re: Connection with R-Project
« Reply #7 on: February 17, 2013, 12:02:22 pm »
The code provided by Dieter Menne is interesting, but not versatile. It uses COM interfaces and DLLs making the software restricted to Windows.

A cross-platform solution would be preferable, e.g. by using embedded shell calls.

I do not care that is only for windows. How would that another solution, using embedded shell calls?
Thanks very much!

pedropadel

  • Newbie
  • Posts: 5
Re: Connection with R-Project
« Reply #8 on: February 17, 2013, 12:03:35 pm »
Quote
Link. How to link a DLL?
You have must declare the function(s) you'd like to call from the dll using external declaration AND call it in your program. The DLL will then be automatically linked.

Please would you have a sample code? Thank you very much!

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Connection with R-Project
« Reply #9 on: February 17, 2013, 01:30:34 pm »
Quote
Please would you have a sample code? Thank you very much!
Read my link

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Connection with R-Project
« Reply #10 on: February 17, 2013, 06:56:51 pm »
The code provided by Dieter Menne is interesting, but not versatile. It uses COM interfaces and DLLs making the software restricted to Windows.

A cross-platform solution would be preferable, e.g. by using embedded shell calls.

I do not care that is only for windows. How would that another solution, using embedded shell calls?
Thanks very much!

This if performed with fpsystem on Unix-based systems. See http://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#Hardware_access_via_encapsulated_shell_calls for an example. The same technique is possible for invoking commands and statements in R (and, of course, other S implementations)
« Last Edit: February 17, 2013, 06:58:57 pm by jwdietrich »
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

 

TinyPortal © 2005-2018