On Tue, 26 Feb 2002 15:34:26 GMT, Wyss Clemens <WYS / helbling.ch>
wrote:

>Hi Robert,
>>it seems to leave a process running in the system
>
>A "ruby.exe" process?

No, an Excel process, or some Excel resource.

>What Ruby version are you running?

1.6

>My "old" 1.6.3 has no problems alike.
>Neither with excel nor with word.

Can you start up an Excel program, then exit the ruby program leaving
Excel running?  That's what seems to hang me up.


>
>> -----Original Message-----
>> From: Robert C. Martin
>> [mailto:u.n.c.l.e.b.o.b. / .o.b.j.e.c.t.m.e.n.t.o.r.d.o.t.c.o.m]
>> Sent: Dienstag, 26. Februar 2002 16:06
>> To: ruby-talk / ruby-lang.org
>> Subject: Re: Using Win32OLE with Excel leaves Excel process hanging
>> 
>> 
>> On Sat, 23 Feb 2002 09:39:25 -0500, Alexander Schofield
>> <pcs3 / mailhost.njit.edu> wrote:
>> 
>> Sorry, I should have been clearer.  The goal is for the Ruby program
>> to quit, leaving the Excel window on the screen.  The user can then
>> look at the Excel window for as long as they like and then close it.
>> By then the Ruby program is long gone.
>> 
>> So what I need is a way for the Ruby program to detach from the excel.
>> program, and leave it running.
>> 
>> 
>> 
>> >Also 
>> >excel.ActiveWorkbook.Close(0);
>> >probably wouldn't be a bad idea.
>> >
>> >It seems like you were expecting a GC to clean up, in Ruby 
>> it can, but
>> >there are problems interfacing with other progs.  Try
>> >ObjectSpace#define_finalizer for a destructor.
>> >
>> >"Robert C. Martin" wrote:
>> >> 
>> >> I have created a neat little ruby program that generates a useful
>> >> graph in Excel.  I keep the program on my desktop and 
>> doubleclick it
>> >> whenever I want to see the graph.  Unfortunately, once I 
>> invoke this
>> >> program, it seems to leave a process running in the system.  After
>> >> 20min or so, it will stop working.  What's more, it often prevents
>> >> other OLE operations from working in other applications.  It can be
>> >> fixed by a logout/logon.  I'm using windows 2000.
>> >> 
>> >> Any ideas?
>> >> 
>> >> Here is the code for AmazonAnalyzer.rb
>> >> 
>> >> require 'AmazonAnalyzer'
>> >> require 'win32ole'
>> >> 
>> >> if __FILE__ == $0
>> >>   periodLength = 7
>> >>   if (ARGV[0] != nil) && (ARGV[0].to_i > 0)
>> >>     periodLength = ARGV[0].to_i
>> >>   end
>> >> 
>> >>   puts "Running Amazon Analyzer with period length #{periodLength}"
>> >> 
>> >>   analyzer = AmazonAnalyzer.new()
>> >>   analyzer.analyzeFile("bookData", periodLength)
>> >> 
>> >>   excel = WIN32OLE.new("excel.application")
>> >>   workbook = excel.Workbooks.Add()
>> >> 
>> >>   col = 'b'
>> >>   row = "1"
>> >>   analyzer.startDate.step(analyzer.endDate,periodLength) {|date|
>> >>     excel.Range(col+row).value = date.to_s
>> >>     col = col.succ
>> >>   }
>> >> 
>> >>   isbns = analyzer.isbns
>> >>   isbns.each {|isbn|
>> >>     col='a'
>> >>     row = row.succ
>> >>     title = analyzer.getTitleFor(isbn)
>> >>     title = title.split(':')[0]
>> >>     title = title.split('(')[0]
>> >>     title = title[0,40]
>> >>     excel.Range(col+row).value = title
>> >> 
>> >>     periods = analyzer.getPeriodsForIsbn(isbn)
>> >>     0.upto(periods.max) {|period|
>> >>       col = col.succ
>> >>       if periods.include?(period)
>> >>         excel.Range(col+row).value =
>> >>           analyzer.getRange(isbn,period).mean
>> >>       end
>> >>     }
>> >>   }
>> >>   xlLine=4
>> >>   xlValue=2
>> >>   xlRows=1
>> >>   xlScaleLogarithmic = -4133
>> >>   excel.Range("a1:"+col+row).Select()
>> >>   excelChart = workbook.Charts.Add()
>> >>   excelChart.type = xlLine
>> >>   excelChart.plotBy=xlRows
>> >>   excelChart.Legend.Font.Size=8
>> >>   excelChart.Axes(xlValue).scaleType = xlScaleLogarithmic
>> >>   excelChart.Axes(xlValue).minimumScale = 100
>> >> 
>> >>   workbook.saved = true
>> >>   excel.visible = true
>> >> end
>> >> 
>> >> Robert C. Martin  | "Uncle Bob"
>> >> Object Mentor Inc.| unclebob @ objectmentor . com
>> >> PO Box 5757       | Tel: (800) 338-6716
>> >> 565 Lakeview Pkwy | Fax: (847) 573-1658           | 
>www.objectmentor.com
>>> Suite 135         |                               | www.XProgramming.com
>>> Vernon Hills, IL, | Training and Mentoring        | www.junit.org
>>> 60061             | OO, XP, Java, C++, Python     |
>>> 
>>> "One of the great commandments of science is:
>>>     'Mistrust arguments from authority.'" -- Carl Sagan
>
>Robert C. Martin  | "Uncle Bob"                   
>Object Mentor Inc.| unclebob @ objectmentor . com
>PO Box 5757       | Tel: (800) 338-6716         
>565 Lakeview Pkwy | Fax: (847) 573-1658           | www.objectmentor.com
>Suite 135         |                               | www.XProgramming.com
>Vernon Hills, IL, | Training and Mentoring        | www.junit.org
>60061             | OO, XP, Java, C++, Python     |
>
>"One of the great commandments of science is:
>    'Mistrust arguments from authority.'" -- Carl Sagan

Robert C. Martin  | "Uncle Bob"                   
Object Mentor Inc.| unclebob @ objectmentor . com
PO Box 5757       | Tel: (800) 338-6716         
565 Lakeview Pkwy | Fax: (847) 573-1658           | www.objectmentor.com
Suite 135         |                               | www.XProgramming.com
Vernon Hills, IL, | Training and Mentoring        | www.junit.org
60061             | OO, XP, Java, C++, Python     |

"One of the great commandments of science is:
    'Mistrust arguments from authority.'" -- Carl Sagan