runprogram - need help

Mac OSX specific forum
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

runprogram - need help

Post by michel51 »

Hello List,

in a project I want to compile a given PB-file.
but the following code (example) don't work.

Code: Select all

FileChoose$ = OpenFileRequester("", "", "*.pb", 0)

MessageRequester("choosen file", FileChoose$) ; #############

	myProg = RunProgram(#PB_Compiler_Home + "compilers/pbcompiler", #DQUOTE$+"--executable"+#DQUOTE$+#DQUOTE$+FileChoose$+#DQUOTE$, "", #PB_Program_Open)    
	Debug myProg
	
	While ProgramRunning(myProg)
		Debug "program running"
	Wend
	
	Debug "runprogram finished"
The compiler seems to run, but no application will be created.
Also I tried a lot of combinations in "parameters" with the same result.
What is wrong?

BTW, the example in the help works as expected.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: runprogram - need help

Post by helpy »

Hello,

Have a look at the commandline options:

Code: Select all

Quick Help:
-----------

pbcompiler "filename.pb"

Options:
--------
...
-e or --executable "filename": Create an executable to the given filename
...
If you change your code, you can see, that the passed parameters are wrong:

Code: Select all

EnableExplicit

Define FileChoose$, Parameter$, myProg

FileChoose$ = OpenFileRequester("", "", "*.pb", 0)

MessageRequester("choosen file", FileChoose$) ; #############

Parameter$ = #DQUOTE$+"--executable"+#DQUOTE$+#DQUOTE$+FileChoose$+#DQUOTE$
Debug Parameter$

myProg = RunProgram(#PB_Compiler_Home + "compilers/pbcompiler", Parameter$, "", #PB_Program_Open)
Debug myProg

While ProgramRunning(myProg)
  Debug "program running"
Wend

Debug "runprogram finished"
Result of Parameter$:

Code: Select all

"--executable""/path/to/source-code.pb"
Solution: Change your code, so that the Result of Parameter$ looks like this:

Code: Select all

--executable "/path/to/new-executable" "/path/to/source-code.pb"
If you will pass this as Parameter to RunProgram, it should work.

cu,
guido
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Re: runprogram - need help

Post by michel51 »

Hi helpy,

thanks for your answer.
I tried and tested a lot of combinations for parameters, but an app will not be created.
My last try is here:

Code: Select all

sFile.s = OpenFileRequester("", "", ".pb", 0)
appFile.s = ReplaceString(sFile, ".pb", ".app")
RunProgram(#PB_Compiler_Home + "compilers/pbcompiler", sFile + " -e " + appFile, GetPathPart(sFile), #PB_Program_Wait)
This is from a short snippet, that creates me a resident. It's modified for compiling to an application, but nothing happens.
A resident-file will be compiled.

May be the parameter "-e" or "--executable" buggy and works on Mac not correctly.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: runprogram - need help

Post by J. Baker »

Works just fine. Try it with Chr(34). ;)

Code: Select all

sFile.s = OpenFileRequester("", "", ".pb", 0)
appFile.s = ReplaceString(sFile, ".pb", ".app")
RunProgram(#PB_Compiler_Home + "compilers/pbcompiler", Chr(34) + sFile + Chr(34) + " -e " + Chr(34) + appFile + Chr(34), GetPathPart(sFile), #PB_Program_Wait)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Re: runprogram - need help

Post by michel51 »

J. Baker wrote:Works just fine. Try it with Chr(34). ;)

Code: Select all

sFile.s = OpenFileRequester("", "", ".pb", 0)
appFile.s = ReplaceString(sFile, ".pb", ".app")
RunProgram(#PB_Compiler_Home + "compilers/pbcompiler", Chr(34) + sFile + Chr(34) + " -e " + Chr(34) + appFile + Chr(34), GetPathPart(sFile), #PB_Program_Wait)
Hmmm... tried, but nothing happens.
Don't know, what is wrong or missing (?)
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: runprogram - need help

Post by helpy »

Is the source file correct? Maybe the compiler does not finish creating the application because of an syntax error?
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Re: runprogram - need help

Post by michel51 »

I think, I got it :!:

The code really works as expected.
In the code I used for testing I have used the compiler constant "#PB_Editor_CreateExecutable". This constant is useful for testing if I compiled a source to an application from IDE or if I run the code in IDE (compile/run).
But in this case the constant generates an error ( "Constant #PB_Editor_CreateExecutable not found").
The same if I try to compile in command line terminal.

Hmm, looks like a bug, because the compiler is the same in all cases.
I will further try it and eventually post an bug later.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: runprogram - need help

Post by helpy »

It is not a bug!

The constants #PB_Editor_CompileCount, #PB_Editor_BuildCount, #PB_Editor_CreateExecutable are special EDITOR constants, which only work, when compiling from the editor! Have a look at the PureBasic documentation:

==> http://www.purebasic.com/documentation/ ... piler.html

cu,
guido
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: runprogram - need help

Post by J. Baker »

michel51 wrote:
J. Baker wrote:Works just fine. Try it with Chr(34). ;)

Code: Select all

sFile.s = OpenFileRequester("", "", ".pb", 0)
appFile.s = ReplaceString(sFile, ".pb", ".app")
RunProgram(#PB_Compiler_Home + "compilers/pbcompiler", Chr(34) + sFile + Chr(34) + " -e " + Chr(34) + appFile + Chr(34), GetPathPart(sFile), #PB_Program_Wait)
Hmmm... tried, but nothing happens.
Don't know, what is wrong or missing (?)
Don't copy and paste from Safari. It doesn't work. Use Firefox. ;)

If that's indeed what you did or not.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Re: runprogram - need help

Post by michel51 »

J. Baker wrote: Don't copy and paste from Safari. It doesn't work. Use Firefox. ;)

If that's indeed what you did or not.
I know that. I use another way for "copy and paste" from Safari.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Re: runprogram - need help

Post by michel51 »

helpy wrote:It is not a bug!

The constants #PB_Editor_CompileCount, #PB_Editor_BuildCount, #PB_Editor_CreateExecutable are special EDITOR constants, which only work, when compiling from the editor! Have a look at the PureBasic documentation:

==> http://www.purebasic.com/documentation/ ... piler.html

cu,
guido
You're right. But as I've said above the source with this constants are testing codes form the past.
And till now I don't needed runprogram in this way.
But now I know that and I will avoid this mistake from now on.
Thanks for your help.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
Post Reply