1. Running one program from another

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

new topic     » topic index » view message » categorize

2. Re: Running one program from another

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Running one program from another

ghaberek said...

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: Running one program from another

eukat said...
ghaberek said...

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.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Running one program from another

jimcbrown said...
eukat said...
ghaberek said...

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

new topic     » goto parent     » topic index » view message » categorize

6. Re: Running one program from another

DonCole said...

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

new topic     » goto parent     » topic index » view message » categorize

7. Re: Running one program from another

ghaberek said...
DonCole said...

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu