From: Damphyr Date: 2005-09-09T22:27:40+09:00 Subject: Re: win32ole confusion Well, I managed to confuse myself even more. I moved the code outside the application and it works. So I probably screwed up. module Test class FinderException OK, I'm trying to wade my way through Rationals Rose RealTime using > their extensibility interface, just to get some information out of > *various* models. > So I need to load one model, do some work, open another model do some > work etc. > > The following code works without a problem: > require 'win32ole' > modelname="some_model" > app=WIN32OLE.new('RoseRT.Application') > model=app.OpenModel(modelname) > app.visible > and at the end of the script the RoseRT.Application process is exited. > > If I put the same code in an initialize method for a class > > class Finder > def initialize modelname > @app=WIN32OLE.new('RoseRT.Application') > @model=@app.OpenModel(modelname) > @app.visible > end > end > > I get the following error > > ./rt_logical.rb:168:in `method_missing': OpenModel (WIN32OLERuntimeError) > OLE error code:0 in > > HRESULT error code:0x80020005 > Type mismatch. from ./rt_logical.rb:168:in `initialize' > from structure.rb:69:in `new' > > If I take the code and put it in a start method in the class > > class Finder2 > def initialize modelname > @modelname=modelname > @model=nil > @app=nil > end > > def start > @app=WIN32OLE.new('RoseRT.Application') > @model=@app.OpenModel(@modelname) > @app.visible > end > > def search objectname > raise RuntimeError,"Finder not started" unless @model > #some search thingy > end > end > > and then execute the following: > > ff=Finder.new('some_model') > begin > ff.search 'capsule' > rescue > ff.start > retry > end > > I got the same error as before (once) and then it worked (although at > the end of the script the RoseRT process is not exited). > Not to forget to mention that the class Finder is in a module. > So what am I missing in the whole create/initialize/destroy cycle that > breaks my script? Do I have some racing condition I need to worry about? > Cheers, > V.- > > > ____________________________________________________________________ > http://www.freemail.gr - ������ �������� ������������ ������������. > http://www.freemail.gr - free email service for the Greek-speaking. > > ____________________________________________________________________ http://www.freemail.gr - ������ �������� ������������ ������������. http://www.freemail.gr - free email service for the Greek-speaking.