1. Running one program from another
- Posted by DonCole Jan 28, 2014
- 1928 views
Hello everybody,
How can I run program A (Al Getz's Launch Pad for example), use it to start and run program B.
Close program A but keep program B running?
Any help appreciated.
Don Cole
2. Re: Running one program from another
- Posted by ghaberek (admin) Jan 29, 2014
- 1896 views
This is what I use...
-- start.e include std/cmdline.e include std/filesys.e include std/search.e include std/sequence.e include std/text.e include std/types.e public function search_path( sequence file_name ) -- search the PATH environment variable for a file sequence PATH = getenv( "PATH" ) if atom( PATH ) then PATH = current_dir() end if sequence paths = split( PATH, PATHSEP, 1 ) for i = 1 to length( paths ) do sequence path = paths[i] if not search:ends( SLASH, path ) then path &= SLASH end if path &= file_name if file_exists( path ) then return path end if end for return "" end function public procedure start( sequence file_name, sequence arguments = {} ) -- start a process with optional arguments sequence command if equal( lower(file_name), lower(filename(file_name)) ) then file_name = search_path( file_name ) end if if not sequence_array( arguments ) then arguments = {arguments} end if ifdef WINDOWS then sequence ComSpec = getenv( "ComSpec" ) -- use ComSpec (cmd.exe) 'start' command to launch the process command = build_commandline( {ComSpec, "/c", "start", file_name} & arguments ) elsedef -- use the background operator '&' to launch the process command = build_commandline( {file_name} & arguments & {"&"} ) end ifdef system_exec( command ) end procedure
-- example include start.e sequence cmdline = command_line() start( "notepad.exe", cmdline[2] )
-Greg
3. Re: Running one program from another
- Posted by useless_ Jan 29, 2014
- 1883 views
This is what I use...
-- start.e include std/cmdline.e include std/filesys.e include std/search.e include std/sequence.e include std/text.e include std/types.e public function search_path( sequence file_name ) -- search the PATH environment variable for a file sequence PATH = getenv( "PATH" ) if atom( PATH ) then PATH = current_dir() end if sequence paths = split( PATH, PATHSEP, 1 ) for i = 1 to length( paths ) do sequence path = paths[i] if not search:ends( SLASH, path ) then path &= SLASH end if path &= file_name if file_exists( path ) then return path end if end for return "" end function <snip>
You could just use dir(file_name). No dir = it does not exist.
useless
4. Re: Running one program from another
- Posted by jimcbrown (admin) Jan 29, 2014
- 1878 views
This is what I use...
-- start.e include std/cmdline.e include std/filesys.e include std/search.e include std/sequence.e include std/text.e include std/types.e public function search_path( sequence file_name ) -- search the PATH environment variable for a file sequence PATH = getenv( "PATH" ) if atom( PATH ) then PATH = current_dir() end if sequence paths = split( PATH, PATHSEP, 1 ) for i = 1 to length( paths ) do sequence path = paths[i] if not search:ends( SLASH, path ) then path &= SLASH end if path &= file_name if file_exists( path ) then return path end if end for return "" end function <snip>
You could just use dir(file_name). No dir = it does not exist.
In place of the call to file_exists() ? Agreed. In fact, at least in some cases, file_exists() is implemented using this very method.
5. Re: Running one program from another
- Posted by DonCole Feb 22, 2014
- 1728 views
This is what I use...
-- start.e include std/cmdline.e include std/filesys.e include std/search.e include std/sequence.e include std/text.e include std/types.e public function search_path( sequence file_name ) -- search the PATH environment variable for a file sequence PATH = getenv( "PATH" ) if atom( PATH ) then PATH = current_dir() end if sequence paths = split( PATH, PATHSEP, 1 ) for i = 1 to length( paths ) do sequence path = paths[i] if not search:ends( SLASH, path ) then path &= SLASH end if path &= file_name if file_exists( path ) then return path end if end for return "" end function <snip>
You could just use dir(file_name). No dir = it does not exist.
In place of the call to file_exists() ? Agreed. In fact, at least in some cases, file_exists() is implemented using this very method.
Thank you, jimbrown, eukat, and ghaberek,
This all well and good. But like I said I am using Al Getz's Launch Pad 403 (I know where it is on my computer).
What I want to know is how do I shut down LP403.exw or LP403.exe with out shutting down the program I am launching?
Thank you,
Don Cole
6. Re: Running one program from another
- Posted by ghaberek (admin) Feb 22, 2014
- 1704 views
Thank you, jimbrown, eukat, and ghaberek,
This all well and good. But like I said I am using Al Getz's Launch Pad 403 (I know where it is on my computer).
What I want to know is how do I shut down LP403.exw or LP403.exe with out shutting down the program I am launching?
Thank you,
Don Cole
I'm not sure how Al Getz' Launch Pad works, but just call start() to launch something, and then exit the app.
You may have to use abort(0) to exit immediately.
But whatever you run with start() should stay running after your app exits.
-Greg
7. Re: Running one program from another
- Posted by DonCole May 16, 2014
- 1444 views
Thank you, jimbrown, eukat, and ghaberek,
This all well and good. But like I said I am using Al Getz's Launch Pad 403 (I know where it is on my computer).
What I want to know is how do I shut down LP403.exw or LP403.exe with out shutting down the program I am launching?
Thank you,
Don Cole
I'm not sure how Al Getz' Launch Pad works, but just call start() to launch something, and then exit the app.
You may have to use abort(0) to exit immediately.
But whatever you run with start() should stay running after your app exits.
-Greg
A belated thanks to you Greg. I had trouble figuring where to put the abort(0) but I got it. Launch Pad is closing now after program launch.
Don Cole