How to run a program in a new window

General FreeBASIC programming questions.
BobPaw
Posts: 41
Joined: Dec 13, 2014 2:03
Location: Texas, USA

How to run a program in a new window

Postby BobPaw » Jul 18, 2015 3:10

How would I run a program in a new window, creating a new process, and delivering control to both programs?
St_W
Posts: 1494
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: How to run a program in a new window

Postby St_W » Jul 18, 2015 10:23

BobPaw wrote:How would I run a program in a new window, creating a new process, and delivering control to both programs?

You can either use CreateProcess from the Windows API or call start via SHELL:

Code: Select all

shell "cmd /c ""start myprogram.exe"""

(assuming you are using FreeBasic on a multitasking OS like Windows; of course this isn't possible in DOS)
speedfixer
Posts: 398
Joined: Nov 28, 2012 1:27
Location: California

Re: How to run a program in a new window

Postby speedfixer » Jul 19, 2015 15:47

Also available:

Code: Select all

dim as integer filnum
dim as string anydir, anyexe, txtret

anydir = "/some/directory/"
anyexe = "myprogram"         ' could be shell/bat, system exe, other FB program

filnum = freefile

open pipe (anydir + anyexe + "&") for input as #filnum
   ' linux: "&" leaves program running as stand alone, if needed

input #filnum1, txtret                   ' *may* collect output of 'anyexe' - ymmv
close #filnum



My favorite.

For anyone: would there be an advantage of one method or another?

David
grindstone
Posts: 737
Joined: May 05, 2015 5:35
Location: Germany

Re: How to run a program in a new window

Postby grindstone » Jul 20, 2015 10:40

speedfixer wrote:For anyone: would there be an advantage of one method or another?
Using the 'Pipe'-statement you can write to the standard input of the child process or read from its standard output. For detailed information read the reference.

Return to “General”

Who is online

Users browsing this forum: No registered users and 6 guests