It is currently Sat Oct 31, 2020 11:01 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: RunProgram with #PB_Program_Wait does not wait
PostPosted: Mon May 11, 2020 2:39 pm 
Offline
User
User

Joined: Sun Dec 16, 2018 12:54 pm
Posts: 22
Hi Folks!

In my program I want to start the editor of the OS where it is running to edit a SQL Statement.

In Windows and Linux it runs fine. The editor was started and my program waits until the editor is closed.
On MacOS the Editor is also started, but the program does not wait until the editor is closed.

Her the Coding:

Code:
CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_MacOS
      RunProgram("open","spoc"+Str(ProgramID)+".txt" ,"",#PB_Program_Wait)     
    CompilerCase #PB_OS_Linux
      RunProgram("gedit","spoc"+Str(ProgramID)+".txt","",#PB_Program_Wait)     
    CompilerCase #PB_OS_Windows
      RunProgram("spoc"+Str(ProgramID)+".txt","","",#PB_Program_Wait)
  CompilerEndSelect
 


Any Ideas ?
regards
Jörg


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram with #PB_Program_Wait does not wait
PostPosted: Tue May 12, 2020 10:37 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 22, 2003 7:43 pm
Posts: 620
Location: Germany, Saarbrücken
The problem is that the "open" command looks up which other program it should run for the given file type, then runs that program and exits.

You should get the same issue on Linux if an other 'gedit' instance is already running because it will just put that instance to the foreground, opens the file in it, and exits as well.

_________________
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram with #PB_Program_Wait does not wait
PostPosted: Tue May 12, 2020 4:02 pm 
Offline
User
User

Joined: Sun Dec 16, 2018 12:54 pm
Posts: 22
Thanks for your hint!

I try another RunProgram call and it works so that my program is waiting:

Code:
  CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_MacOS
      RunProgram("/Applications/TextEdit.app/Contents/MacOS/TextEdit",GetCurrentDirectory() + "/spoc"+Str(ProgramID)+".txt" ,"",#PB_Program_Wait)     
    CompilerCase #PB_OS_Linux
      RunProgram("gedit","spoc"+Str(ProgramID)+".txt","",#PB_Program_Wait)     
    CompilerCase #PB_OS_Windows
      RunProgram("spoc"+Str(ProgramID)+".txt","","",#PB_Program_Wait)
  CompilerEndSelect


Now it works!


Top
 Profile  
Reply with quote  
 Post subject: Re: RunProgram with #PB_Program_Wait does not wait
PostPosted: Tue May 19, 2020 2:42 pm 
Offline
User
User

Joined: Sun Dec 16, 2018 12:54 pm
Posts: 22
Hi folks!

I tried an other way to solve the problem:

The open command has a lot of parameters. 2 of them are my coice: -e means that the given file will be opened by the TextEdit App. The -W parameter means that the open command waits of the return of the command. So that is what I need.

Sample:

Code:
      RunProgram("open","-W -e spoc"+pgmid$+".txt" ,"",#PB_Program_Wait)     


regards
Jörg


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye