Page 1 of 2
[4.20] Bug or Problem code ?
Posted: Sat Nov 15, 2008 9:58 am
by Progi1984
Hello
I try to create an archive (.a) from objects files (.o).
No problem in command line. But when i use RunProgram, no archive files generated.
The code and O files are in the zip...
File:1->
Test_AR.zip
Code: Select all
StringTmp.s = "rvs "
StringTmp + chr(34) + "/home/franklin/Bureau/DD_PureBasic/Test.a"+ chr(34) + " "
StringTmp + "/home/franklin/Bureau/DD_PureBasic/*.o"
Debug StringTmp
RunProgram("ar ", StringTmp, "", #PB_Program_Wait)
Thanks in advance for your help.
Posted: Sat Nov 15, 2008 1:19 pm
by Fred
I don't think than runprogram() support '*.o' as this pattern is typically extended by the shell interpreter.
Posted: Sat Nov 15, 2008 2:13 pm
by freak
Yes, RunProgram() does not expand these.
You can try with system_(), it calls a shell, so this should work (also > and < redirection)
http://www.gnu.org/software/libc/manual ... ystem-3150
Posted: Sat Nov 15, 2008 4:08 pm
by Progi1984
May be a feature request for a next version ?

Posted: Sat Nov 22, 2008 11:52 am
by Progi1984
Finally, just a last question, how can i get the directory of pb under Linux ?
I try :
- system_(@"which pbcompiler")
- RunProgram("which", "pbcompiler")
- RunProgram("which pbcompiler")
But no returns...
Have you got an idea ?
Posted: Sat Nov 22, 2008 12:51 pm
by Fred
It's probably not in you PATH variable. There is no way to detect it automatically, but you can define a PUREBASIC_HOME env var and use this value in your programs.
Posted: Sat Nov 22, 2008 1:37 pm
by Progi1984
But when I make a which pbcompiler, this returns that :
Code: Select all
franklin@novatux-laptop:~$ which pbcompiler
/media/DISK/Programs/purebasic/compilers/pbcompiler
Have you got a solution for getting the return of system_(@"which pbcompiler") ?
Posted: Sat Nov 22, 2008 1:45 pm
by Fred
When you use this:
Did you tried with the #PB_Program_Read flags and ReadProgramString() command ?
Posted: Sat Nov 22, 2008 1:51 pm
by Progi1984
I tried this code :
Code: Select all
Compilateur = RunProgram("which", "pbcompiler ", "", #PB_Program_Open|#PB_Program_Read)
Sortie$ = ""
If Compilateur
While ProgramRunning(Compilateur)
Sortie$ + ReadProgramString(Compilateur) + Chr(13)
Wend
Sortie$ + Chr(13) + Chr(13)
Sortie$ + "Code de retour : " + Str(ProgramExitCode(Compilateur))
EndIf
MessageRequester("Sortie", Sortie$)
And Sortie$ returns ""
Posted: Sat Nov 22, 2008 3:18 pm
by Fred
is space in "pbcompiler> <" intentional ? Are you executing your pogram from the same shell which show an output with 'which' ?
Posted: Sat Nov 22, 2008 3:20 pm
by Progi1984
No, but that doesn't change anything.
Posted: Sat Nov 22, 2008 3:50 pm
by flaith
have you tried with another program ? Same issue ?
Posted: Sat Nov 22, 2008 3:51 pm
by Progi1984
For RunProgram, yes, with "ar" !
Posted: Sat Nov 22, 2008 6:30 pm
by flaith
Progi1984 wrote:For RunProgram, yes, with "ar" !

forgot your first post
with a "which -a pbcompiler", what does it gives you ?
Posted: Sat Nov 22, 2008 6:34 pm
by Progi1984
Code: Select all
Compilateur = RunProgram("which", "-a pbcompiler", "", #PB_Program_Open|#PB_Program_Read)
Sortie$ = ""
If Compilateur
While ProgramRunning(Compilateur)
Sortie$ + ReadProgramString(Compilateur) + Chr(13)
Wend
Sortie$ + Chr(13) + Chr(13)
Sortie$ + "Code de retour : " + Str(ProgramExitCode(Compilateur))
EndIf
MessageRequester("Sortie", Sortie$)
Negative, returns an empty string.