Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-07

Trying to use TProcess to run Open Office calc

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark E. Skeels

Hello, All,

I'm trying to run the following code.

It runs if I leave the option line commented out.

If I uncomment the option line it hangs.

This did not happen until I downloaded the latest version of Open Office this AM.

I was running Open Office 3.1. (worked as expected)

I am now running Open Office 3.3. (hangs and Open Office Calc never starts)

I saw the warnings about using pipes and reading information back; I am not doing any of this; just trying to open the spreadsheet, edit it, and close it while waiting to return in the Lazarus program.

When I reset the debugger calc opens as expected.

I'm running under Windows Vista.

Any idea what is going on, please?

   AProcess := TProcess.Create(nil);
   AProcess.CommandLine := 'C:\Program Files\OpenOffice.org
3\program\scalc.exe ' + CurrentProcessFileName;
//    AProcess.Options := AProcess.Options + [poWaitOnExit];
   AProcess.execute;
   AProcess.Free;

Thanks,
Mark

"If your creed and Scripture do not agree, cut your creed to pieces, but make it agree with this book." ~Charles Spurgeon~ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110722/3f0bc1c7/attachment.html>

Reply by email

Ludo Brands
to Mark E. Skeels

Tried this with OO 3.3.0 (OOO330m13 and OOO330m20) on XP and it worked just fine, with or without the commented line.
The path contains a space character which should be avoided. I would suggest (assuming CurrentProcessFileName ins't double quoted) :

AProcess.CommandLine := '"C:\Program Files\OpenOffice.org
3\program\scalc.exe" "' + CurrentProcessFileName +'"';

Another point you need to pay attention to: scalc.exe doesn't do much more than launching soffice.exe which in turn creates a process soffice.bin. When you close the openoffice app, depending on your config you can still have soffice.exe hanging around (icon in notification area of the taskbar). This means that the wait on exit will last sometimes longer thatn you intended. Also if soffice.exe is in your tasklist, starting scalc.exe will return the wait on exit immediately because it will just launch a new task in the already running soffice.exe.

Ludo

Earlier message 53 lines
-----Message d'origine----- De : Mark E. Skeels [mailto:] Envoy? : vendredi 22 juillet 2011 17:42 ? : Objet : [Lazarus] Trying to use TProcess to run Open Office calc Hello, All, I'm trying to run the following code. It runs if I leave the option line commented out. If I uncomment the option line it hangs. This did not happen until I downloaded the latest version of Open Office this AM. I was running Open Office 3.1. (worked as expected) I am now running Open Office 3.3. (hangs and Open Office Calc never starts) I saw the warnings about using pipes and reading information back; I am not doing any of this; just trying to open the spreadsheet, edit it, and close it while waiting to return in the Lazarus program. When I reset the debugger calc opens as expected. I'm running under Windows Vista. Any idea what is going on, please? AProcess := TProcess.Create(nil); AProcess.CommandLine := 'C:\Program Files\OpenOffice.org 3\program\scalc.exe ' + CurrentProcessFileName; // AProcess.Options := AProcess.Options + [poWaitOnExit]; AProcess.execute; AProcess.Free; Thanks, Mark -- "If your creed and Scripture do not agree, cut your creed to pieces, but make it agree with this book." ~Charles Spurgeon~

Reply by email

Mark E. Skeels
to Ludo Brands

Ludo,

Thank you for the input.

As we could probably expect, adding the quotes as you suggested made no difference in my case.

Scalc still will not open (and my app still hangs) when using the flag.

Thanks for the other info though; I did not know that.

Mark

Ludo Brands wrote 67 lines
Tried this with OO 3.3.0 (OOO330m13 and OOO330m20) on XP and it worked just fine, with or without the commented line. The path contains a space character which should be avoided. I would suggest (assuming CurrentProcessFileName ins't double quoted) : AProcess.CommandLine := '"C:\Program Files\OpenOffice.org 3\program\scalc.exe" "' + CurrentProcessFileName +'"'; Another point you need to pay attention to: scalc.exe doesn't do much more than launching soffice.exe which in turn creates a process soffice.bin. When you close the openoffice app, depending on your config you can still have soffice.exe hanging around (icon in notification area of the taskbar). This means that the wait on exit will last sometimes longer thatn you intended. Also if soffice.exe is in your tasklist, starting scalc.exe will return the wait on exit immediately because it will just launch a new task in the already running soffice.exe. Ludo -----Message d'origine----- De : Mark E. Skeels [mailto:] Envoy? : vendredi 22 juillet 2011 17:42 ? : Objet : [Lazarus] Trying to use TProcess to run Open Office calc Hello, All, I'm trying to run the following code. It runs if I leave the option line commented out. If I uncomment the option line it hangs. This did not happen until I downloaded the latest version of Open Office this AM. I was running Open Office 3.1. (worked as expected) I am now running Open Office 3.3. (hangs and Open Office Calc never starts) I saw the warnings about using pipes and reading information back; I am not doing any of this; just trying to open the spreadsheet, edit it, and close it while waiting to return in the Lazarus program. When I reset the debugger calc opens as expected. I'm running under Windows Vista. Any idea what is going on, please? AProcess := TProcess.Create(nil); AProcess.CommandLine := 'C:\Program Files\OpenOffice.org 3\program\scalc.exe ' + CurrentProcessFileName; // AProcess.Options := AProcess.Options + [poWaitOnExit]; AProcess.execute; AProcess.Free; Thanks, Mark
"If your creed and Scripture do not agree, cut your creed to pieces, but make it agree with this book." ~Charles Spurgeon~

Reply by email