Launch multiple programs through one tool?

Discussion Forums discussion Launch multiple programs through one tool?

This topic contains 0 voices and has 5 replies.

Viewing 6 posts - 1 through 6 (of 6 total)
Author Posts
Author Posts
January 16, 2009 at 6:39 am #519

Zetty
Member

Not much else to add. I am starting to learn Flex and after it compiles my stuff, I’d love for it to try and launch the resulting .swf file without me needing to push another button!

January 19, 2009 at 11:59 am #16192

simon
Key Master

Hi, this is most easily done by creating a batch file that runs your two programs, e.g.

@echo off
program1.exe %1 %2 %3 %4
start %2.swf

Call the batch file with all the properties you need from Programmer’s Notepad, and they’ll be in the batch file as %1, %2, …

February 8, 2009 at 9:55 am #16193

Karmaflute
Member

It would be convenient if PN passed the tool command to a hidden command prompt instead. Then we can use fancy stuff like && to do this: "g++ somefile.cpp && out.exe" where out.exe is only run if compilation is successful.

February 16, 2009 at 6:25 am #16194

max
Member

Hi everyone ,

I made a tiny program for PN to run several tools at a time

here is the readme file:


pnbuilder

you can use this program to run several tools at a time.

the tools you need to run have to be config in config.ini

usage:

pnbuilder FullFilePath WorkPath [ProjectName]

the symbols used in the config file are similar to PN :

%f


> file name eg. abc.c

%F


> file name with full path eg. D:abcabc.c

%n


> file name no ext eg. abc

%d


> file path eg. D:abc

%p


> project name

%D


> current work path

the configuration is simple, for example:

in my config.ini, I wrote:

[1]

exe=D:toolskeilC51BINC51.exe

param=%F

[2]

exe=D:toolskeilC51BINBL51.EXE

param=%d%n.obj to %d%n

[3]

exe=D:toolskeilC51BINOH51.EXE

param=%d%n

if I use this command to launch pnbuilder:

pnbuilder D:abcabc.c D:abc

the following command will be launch in D:abc:

D:toolskeilC51BINC51.exe D:abcabc.c ;this command will generate an .obj file

if no error and wanning found,the following command will be launch:

D:toolskeilC51BINBL51.EXE D:abcabc.obj to D:abcabc ;link a file with no ext

and again if no error and wanning found,the following command will be launch:

D:toolskeilC51BINOH51.EXE D:abcabc ;generate a hex file

sorry for my poor English and hope this tiny program can help you

max

trlsmax@gmail.com

16/2/2009


you can download it here

http://www.levelspace.net/up_files/upload/pnbuilder.zip

hope you like it.

February 18, 2009 at 6:33 am #16195

Karmaflute
Member

Thanks, max. Would you mind providing the source code as well?

February 19, 2009 at 4:02 am #16196

max
Member

here is the code,in delphi

Code:
program pnbuilder;

{$APPTYPE CONSOLE}

uses
Windows, SysUtils, IniFiles, StrUtils;

var
hReadPipe, hWritePipe: THandle;
si : STARTUPINFO;
lsa : SECURITY_ATTRIBUTES;
pi : PROCESS_INFORMATION;
cchReadBuffer : DWORD;
ph : PChar;
fname : PChar;
cmd, param, section : string;
ExistCode : Dword;
config : TIniFile;
i : integer;
begin
if (paramcount = 0) or (paramcount < 2) or (paramcount > 3) then
begin
writeln(‘PN Builder by Max’);
writeln(‘usage:pnbuilder FullFilePath WorkPath [ProjectName]‘);
exit;
end;
i := 1;
fname := allocmem(255);
ph := AllocMem(5000);
lsa.nLength := sizeof(SECURITY_ATTRIBUTES);
lsa.lpSecurityDescriptor := nil;
lsa.bInheritHandle := True;
config := TIniFile.Create(ExtractFilePath(Paramstr(0))+’config.ini’);

if CreatePipe(hReadPipe, hWritePipe, @lsa, 0) = false then
begin
writeln(‘Can not create pipe!’);
exit;
end;
fillchar(si, sizeof(STARTUPINFO), 0);
si.cb := sizeof(STARTUPINFO);
si.dwFlags := (STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW);
si.wShowWindow := SW_SHOW;
si.hStdOutput := hWritePipe;

repeat
begin
section := IntToStr(i);
param := config.ReadString(section,’param’,'NA’);
if AnsiContainsStr(param,’%f’) then
param := AnsiReplaceStr(param,’%f’,ExtractFileName(ParamStr(1)));
if AnsiContainsStr(param,’%F’) then
param := AnsiReplaceStr(param,’%F’,ParamStr(1));
if AnsiContainsStr(param,’%n’) then
param := AnsiReplaceStr(param,’%n’,ChangeFileExt(ExtractFileName(ParamStr(1)),”));
if AnsiContainsStr(param,’%d’) then
param := AnsiReplaceStr(param,’%d’,ExtractFilePath(ParamStr(1)));
if AnsiContainsStr(param,’%P’) then
param := AnsiReplaceStr(param,’%P’,ParamStr(3));
if AnsiContainsStr(param,’%D’) then
param := AnsiReplaceStr(param,’%D’,ParamStr(2));
cmd := config.ReadString(section,’exe’,'NA’)+’ ‘+param;
if CreateProcess(nil, PChar(cmd), nil, nil, true, 0, nil, PChar(ParamStr(2)), si, pi) = False then
begin
writeln(‘can not create process’);
FreeMem(ph);
FreeMem(fname);
Exit;
end;

while (true) do
begin
if not PeekNamedPipe(hReadPipe, ph, 1, @cchReadBuffer, nil, nil) then
break;
if cchReadBuffer <> 0 then
begin
if ReadFile(hReadPipe, ph^, 8192, cchReadBuffer, nil) = false then
break;
ph[cchReadbuffer] := chr(0);
writeln(ph);
end
else if (WaitForSingleObject(pi.hProcess, 0) = WAIT_OBJECT_0) then
begin
GetExitCodeProcess(pi.hProcess,ExistCode) ;
i := i+1;
break;
end;
end;
end;
Until ((ExistCode > 0) or (config.ReadString(IntToStr(i),’exe’,'NA’) = ‘NA’));

ph[cchReadBuffer] := chr(0);
writeln(ph);
CloseHandle(hReadPipe);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
CloseHandle(hWritePipe);
FreeMem(ph);
FreeMem(fname);

end.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.