Restored from previous forum. Originally posted by Fangbeast.
Anyone know how to add some sort of SYNCHRONOUS behaviour to RunProgram? The program I wrote will be used on so many different speed systems that my shelling out to external programs could well stuff up the rest of the code.
Using DELAY is not a good idea because it doesn't take into account different CPU speeds.
If I add the RunProgram routine to a separate procedure, would this have a Synchronous effect??
Regards
Fangles
add SYNCHRONOUS behaviour to RunProgram??
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
runprogram("calc.exe","",0)
delay(1000) ; Just to give calc some time to open
repeat : r=findwindow_(0,"Calculator") : until r=0
messagerequester("done!","calc exited",0)
end
Yes, you can do it many ways depending on what you need. For example, here's a way to launch the Windows calculator and halt program execution until you close the calc:Anyone know how to add some sort of SYNCHRONOUS behaviour to RunProgram?
runprogram("calc.exe","",0)
delay(1000) ; Just to give calc some time to open

repeat : r=findwindow_(0,"Calculator") : until r=0
messagerequester("done!","calc exited",0)
end
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
. I've added the possibility to run an app scynchronously and to hide it if necessary to RunProgram()... For the next release
Edited by - fred on 19 October 2001 16:13:32
This don't work on non-english Windows, think about it.. Here it's "Calculatrice"[runprogram("calc.exe","",0)
delay(1000) ; Just to give calc some time to open
repeat : r=findwindow_(0,"Calculator") : until r=0
messagerequester("done!","calc exited",0)
end

Edited by - fred on 19 October 2001 16:13:32
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
But I'm glad to see that you've added a syncronous version of RunProgram to the next release -- thanks for that!
It was just an example to show one way of doing it.This don't work on non-english Windows, think about it.. Here it's "Calculatrice".

-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
Fred's willingness to help is one of the main reasons I stopped using Visual Basic (what a waste of $900!) and paid for PureBasic.
BTW, Fangbeast, what part of Oz are you from? I'm in Sydney.
Yes, Fred is DA MAN!Fred, I hope I told you lately, you are a legend

BTW, Fangbeast, what part of Oz are you from? I'm in Sydney.
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
PB - Registered PureBasic Coder
Edited by - PB on 29 November 2001 03:51:36
Is there a way to run an external program but still continue your PureBasic app until the external program ends? What I need to do is launch an external app, but then keep my PureBasic program doing things until the other app closes. The other app uses different window captions so I can't check for their existence... I guess what I need is something like this:I've added the possibility to run an app scynchronously and to hide it if necessary to RunProgram()...
Code: Select all
RunProgram("otherapp.exe","",1) ; Run app and tell PureBasic to know when it's closed.
Repeat
; Do my other stuff here until other app closes...
Until OtherAppCloses
End
Edited by - PB on 29 November 2001 03:51:36
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by wavemaker.
Well, the next code does NOT work, but it should XXDDDDD:
Hope it helps, bye,
Juan Calderón Alonso
Registered user
Edited by - wavemaker on 29 November 2001 09:11:29
Well, the next code does NOT work, but it should XXDDDDD:
Code: Select all
si.STARTUPINFO
pi.PROCESS_INFORMATION
#STILL_ACTIVE = $103
GetStartupInfo_(@si)
appname.s = "C:\Windows\Notepad.exe"
; This should work if PB accepted 10 parameters for CreateProcess_, and not 13, as it does.
If CreateProcess_(@appname, 0, 0, 0, 0, 0, 0, 0, @si, @pi)
ExitCode = #STILL_ACTIVE
While ExitCode = #STILL_ACTIVE ; Here goes your program loop, exits when you close Notepad
GetExitCodeProcess_(pi\hProcess, @ExitCode)
Wend
MessageRequester("Message",appname + " terminated.",0)
EndIf
Juan Calderón Alonso
Registered user
Edited by - wavemaker on 29 November 2001 09:11:29
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
Use the new Thread library (v2.70 available) and when the program end set the variable to on:
Fred - AlphaSND
Use the new Thread library (v2.70 available) and when the program end set the variable to on:
Code: Select all
Procedure prog(a)
Shared IsFinished
RunProgram(...,1)
IsFinished = 1
endprocedure
Repeat
...
Until IsFinished = 1