Here is what walk with a cmd files
"C:\Program Files (x86)\gs\gs9.20\bin\gswin32c.exe " -dBATCH -dPDFSETTINGS=/screen -dPDFA=3 -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -dUseCIEColor -sDEVICE=pdfwrite -o "C:\Users\Patrick\Desktop\avis1.pdf" -dPDFACompatibilityPolicy=1 "C:\Users\Patrick\Documents\SEPA\SEPA_EN_COURS\SEPAMAIL\pdfa\PDFA_def.ps" "C:\Users\Patrick\Desktop\factureun.pdf" >toto.txt
I don't arrive to launch the program with purebasic and i don't know ho to do ?
Can someone help me
Launching Ghostscript with parameters How to ?
-
- Enthusiast
- Posts: 546
- Joined: Tue Oct 14, 2014 12:09 pm
- Michael Vogel
- Addict
- Posts: 2799
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Launching Ghostscript with parameters How to ?
Maybe you can try something like this...
Code: Select all
GhostHandle=RunProgram("gswinc.exe","....","",#PB_Program_Read|#PB_Program_Open|#PB_Program_Hide)
If GhostHandle
While ProgramRunning(GhostHandle)
If AvailableProgramOutput(GhostHandle)
s=ReadProgramString(GhostHandle)
EndIf
Wend
GhostExitcode=ProgramExitCode(GhostHandle)
KillProgram(GhostHandle)
CloseProgram(GhostHandle)
Delay(50)
EndIf
Re: Launching Ghostscript with parameters How to ?
Code: Select all
Program$ = "C:\Program Files (x86)\gs\gs9.20\bin\gswin32c.exe"
Parameter$ = "-dBATCH -dPDFSETTINGS=/screen -dPDFA=3 -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -dUseCIEColor -sDEVICE=pdfwrite -o " + #DQUOTE$ + "C:\Users\Patrick\Desktop\avis1.pdf" + #DQUOTE$ + " -dPDFACompatibilityPolicy=1 " + #DQUOTE$ + "C:\Users\Patrick\Documents\SEPA\SEPA_EN_COURS\SEPAMAIL\pdfa\PDFA_def.ps" + #DQUOTE$ + " " + #DQUOTE$ + "C:\Users\Patrick\Desktop\factureun.pdf" + #DQUOTE$
RunProgram(Program$, Parameter$)
Code: Select all
#PB_Program_Read|#PB_Program_Open
Bernd
Re: Launching Ghostscript with parameters How to ?
I don't know what these are. You should give loulou2522 "Chr(34)" instead.infratec wrote: #DQUOTE$
@Michael Vogel
it should be:
s$ = ReadProgramString....
@loulou2522
This worked for me i.e. it generated the "log.txt" file containing an error:
Code: Select all
prog = RunProgram("C:\Program Files (x86)\GPLGS\gswin32c.exe","-dBATCH -dPDFSETTINGS=/screen -dPDFA=3 -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -dUseCIEColor -sDEVICE=pdfwrite -o " + Chr(34) + "C:\Users\phil\AppData\Local\Temp\gswin.pdf" + Chr(34) + " -dPDFACompatibilityPolicy=1 " + Chr(34) + "C:\Program Files (x86)\GPLGS\align.ps" + Chr(34) + " " + Chr(34) + "C:\Users\phil\AppData\Local\Temp\gswin2.pdf" + Chr(34) + " >C:\Users\phil\AppData\Local\Temp\log.txt","c:\",#PB_Program_Read|#PB_Program_Open)
If prog = 0
Debug "Error"
Else
CloseProgram(prog)
EndIf
So I changed my program to follow Michael proposal and it works like a charm:
Code: Select all
prog = RunProgram("C:\Program Files (x86)\GPLGS\gswin32c.exe","-dBATCH -dPDFSETTINGS=/screen -dPDFA=3 -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -dUseCIEColor -sDEVICE=pdfwrite -o " + Chr(34) + "C:\Users\phil\AppData\Local\Temp\gswin.pdf" + Chr(34) + " -dPDFACompatibilityPolicy=1 " + Chr(34) + "C:\Program Files (x86)\GPLGS\align.ps" + Chr(34) + " " + Chr(34) + "C:\Users\phil\AppData\Local\Temp\gswin2.pdf" + Chr(34) + " >C:\Users\phil\AppData\Local\Temp\gswin.txt","c:\",#PB_Program_Read|#PB_Program_Open)
If prog
While ProgramRunning(prog)
If AvailableProgramOutput(prog)
s$ = ReadProgramString(prog)
EndIf
Wend
Debug s$
KillProgram(prog)
CloseProgram(prog)
EndIf
Re: Launching Ghostscript with parameters How to ?
#DQUOTE$ is a constant which represents the value of Chr(34)elwood wrote:I don't know what these are. You should give loulou2522 "Chr(34)" instead.infratec wrote: #DQUOTE$
But if you read #D(ouble)QUOTE$ you know what it is. Chr(34) is only a number converted to a Character.
So for better reading of the code I prefer
#DQUOTE$ for Chr(34)
and
#CRLF$ for Chr(10) + Chr(13)
Bernd
Re: Launching Ghostscript with parameters How to ?
Oh, these constants are not listed in the constant section of the PB manual.
Thanks for the hint.
Thanks for the hint.
Re: Launching Ghostscript with parameters How to ?
In the IDE...take a look at the 'Structure Viewer' on the Tools menu (or simply press Alt-S), then select the 'Constants' tab.elwood wrote:Oh, these constants are not listed in the constant section of the PB manual.
Type in what you need in the box provided, etc.
- It was too lonely at the top.
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem