RunProgram with #PB_Program_Wait does not wait

Mac OSX specific forum
Jörg Burdorf
User
User
Posts: 22
Joined: Sun Dec 16, 2018 12:54 pm

RunProgram with #PB_Program_Wait does not wait

Post by Jörg Burdorf »

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: Select all

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
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: RunProgram with #PB_Program_Wait does not wait

Post by NicTheQuick »

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.
Jörg Burdorf
User
User
Posts: 22
Joined: Sun Dec 16, 2018 12:54 pm

Re: RunProgram with #PB_Program_Wait does not wait

Post by Jörg Burdorf »

Thanks for your hint!

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

Code: Select all

  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!
Jörg Burdorf
User
User
Posts: 22
Joined: Sun Dec 16, 2018 12:54 pm

Re: RunProgram with #PB_Program_Wait does not wait

Post by Jörg Burdorf »

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: Select all

      RunProgram("open","-W -e spoc"+pgmid$+".txt" ,"",#PB_Program_Wait)      
regards
Jörg
Post Reply