Call a program

Just starting out? Need help? Post your questions and find answers here.
bonne
New User
New User
Posts: 3
Joined: Mon Dec 01, 2003 11:50 pm

Call a program

Post by bonne »

I have written programs which run but I cannot call them from menu or from another program. thank you for help. :roll:
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Call a program

Post by ricardo »

bonne wrote:I have written programs which run but I cannot call them from menu or from another program. thank you for help. :roll:
From WHICH menu?

Windows start menu?

Do you want to run another program from the one that you coded?
ARGENTINA WORLD CHAMPION
bonne
New User
New User
Posts: 3
Joined: Mon Dec 01, 2003 11:50 pm

Re: Call a program

Post by bonne »

bonne wrote:I have written programs which run but I cannot call them from menu or from another program. thank you for help. :roll:
With WINDOW98
I try to call my Purebasic Program from another Purebasic pgm. or from Purebasic Menu ( "CreateMenu") , with the help of the example in documentation.:
----
If OpenWindow(0, 100, 150, 195, 260, #pb_Window_SystemMenu, "PureBasic - Menu")
If CreateMenu(0, WindowID())
MenuTitle("File")
MenuItem( 1, "Prg 1")
MenuItem( 7, "&Quit")
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_EventMenu
Select EventMenuID()
Case 1
; >>>>>HERE I CANNOT FIND WHAT TO WRITE TO CALL MY PUREBASIC PROGRAMM !!!!!
Default
MessageRequester("Info", "MenuItem: "+Str(EventMenuID()), 0)
EndSelect
Case #WM_CLOSE ; #PB_EventCloseWindow
Quit = 1
EndSelect
Until Quit = 1
EndIf
-------
thank you again. Regards.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Try the "RunProgram" command.
scurrier
Enthusiast
Enthusiast
Posts: 169
Joined: Sat May 03, 2003 4:10 am

Post by scurrier »

Yes the run program will work, but the program you launch with runprogram will take over as the new program and you will loose the ability to use your parent app. try this I found it works much better


File$="calc.exe"
ShellExecute_(#NULL,"Open",File$,"","",#SW_SHOWNORMAL)

just make sure the File$ points to a program in the Path$ if not you have to include it's path example
calc.exe is in the Windows directory so you dont need it's path
but if you have a program on drive d:\ under a directory called my apps
then you need to do this

File$="D:\My Apps\File.exe"
D:\ is the drive it's located on
My Apps being the directoy it's in
File.exe being the file you want to call

hope this helps

Sean
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

scurrier wrote:Yes the run program will work, but the program you launch with runprogram will take over as the new program and you will loose the ability to use your parent app

Your parent app only pauses execution if you set the RunProgram flag to 1 (which is "Wait until the launched program quits" if we look at the docs)

So it would be incorrect to say that the new program takes over unless you have specifically told it to. :)
Image Image
Post Reply