[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
CAPE-OPEN • View topic - Using COFE from COM

Using COFE from COM

Discusses use of COCO, the process simulation and modelling software suite from AmsterCHEM, downloadable from http://www.cocosimulator.org

Moderator: jasper

Using COFE from COM

Postby HenkF » 25 February 2014, 11:08

Hi,
I'm trying to use COFE from a Lazarus (Free Pascal) setup. I guess this will be quite a struggle, as the COM support of Lazarus has not been fully developed yet.
Nevertheless, using the automation documents you provided I've been able to initialize COFE. I even have been able to generate pascal source from the TLB file!
I'm now trying to load an existing flowsheet into the automation object. This should be done by something like GetObject("FileName.fsd").
Does this mean that I should create the COFE COM object directly from a file? Is there a way to directly load a file into an existing COFE Document (LoadFromstring obviously isn't meant for that, it provides me with a typing error)

Regards,
Henk
HenkF
 
Posts: 87
Joined: 24 February 2013, 14:50
Location: Hengelo,NL

Re: Using COFE from COM

Postby jasper » 25 February 2014, 11:32

LoadFromString and SaveToString match each other; these strings are not file names, but string-encoded (b64) versions of the fsd file content. You should not call LoadFromString on documents that have any content in it:

http://cocosimulator.org/index_help.php ... FromString

Note that COFE is not exposed as just a COM object, but as OLE object; this implies that is requires an OLE site to interact with. The OLE machinery to start from an existing file therefore is supported; I suppose this is what GetObject does in Lazarus. Typically environments that support OLE also support document persistence.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: Using COFE from COM

Postby HenkF » 26 February 2014, 09:31

HenkF
 
Posts: 87
Joined: 24 February 2013, 14:50
Location: Hengelo,NL

Re: Using COFE from COM

Postby jasper » 26 February 2014, 12:11

Not willing to break binary compatibility on the existing interface for that, nor willing to define a new interface for that. Instead, use LoadFromString, and pass "http:///" followed by the file name. Update available via CUP.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: Using COFE from COM

Postby HenkF » 26 February 2014, 14:17

Wow Jasper, thanks man! :D

Sure you shouldn't break the compatibility. Lazarus hasn't been fully matured regarding COM/OLE implementation (it's cross platform, and OLE is a Windows thing), but this will surely help me out.
Recalling the usage: after creating the object I could then use something like Server.LoadFromeString('http:///c:/warmtepomp.rg.h2o.3.1.fsd'); to load an existing flowsheet?

Regards,
Henk
HenkF
 
Posts: 87
Joined: 24 February 2013, 14:50
Location: Hengelo,NL

Re: Using COFE from COM

Postby HenkF » 26 February 2014, 14:29

Got it! Figured out by your update notes. Entering 'file:///' instead of 'http:///', and now it's running! :D :D :D

Thnx
HenkF
 
Posts: 87
Joined: 24 February 2013, 14:50
Location: Hengelo,NL

Re: Using COFE from COM

Postby jasper » 26 February 2014, 14:34

Sorry - typing error. Glad to hear it works.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain


Return to COCO (AmsterCHEM)

Who is online

Users browsing this forum: No registered users and 11 guests