Howto execute external file ...
BlitzMax Forums/BlitzMax Programming/Howto execute external file ...
| ||
How to execute external file (like sh or bat file )from bmx code? Blitz3D has ExecFile(...) and Blitzmax? |
| ||
OpenURL("filename.bat") |
| ||
thx |
| ||
Any idea howto wait on end of executed prgoram? (for showing result) |
| ||
Try system_ such as system_ "notepad.exe" Might also want to lookup createprocess for more control and do a search on execfile for other solutions. |
| ||
OpenURL() should only open a external browser when available. I think you want to use PUB.FreeProcess Local app:String = "notepad.exe" 'Check if file exists If FileType(app) = 1 'Execute application Local process:TProcess = CreateProcess(app) Repeat Local error:String = process.err.ReadLine() If error <> "" Then Notify error EndIf If process.Status() = 0 Then Exit Forever Else Notify "Unable to execute " + app EndIf For my purpose I've left out the repeat block since it was hurting performance for me. But this is how I launch external apps. |
| ||
OpenURL() should only open a external browser when available. OpenURL() will open any file with its default application.If its a HTML file, it'll open it in the default browser. If its a .BMX file, it'll open MaxIDE.exe. etc. |
| ||
@Htbaa: yes. this is good and work nice, thx a lot |
| ||
OpenURL works great, and the host program continues running (this may not be the desired behaviour, but it's a start). System_ works with something like 'System_ "notepad.exe"' but not with a test exe I got from the internet (probably has to do with permissions or security - I have Windows 7 64). TProcess.CreateProcess returns null, even though FileType() shows the file to be executed exists :( TProcess.CreateProcess() is not highlighted in my BlitzMax IDE, so maybe something is wrong? To the point: How does the BlitzMax IDE (or the community edition) call the compiler in the background - I searched but could not find out how - and capture the compiler's output as well? Thanks in advance, Russell |
| ||
Its Local process:TProcess = TProcess.Create() or Local process:TProcess = CreateProcess() Its not highlighted in blitzmax as its undocumented but it works. |
| ||
How does the BlitzMax IDE (or the community edition) call the compiler in the background - I searched but could not find out how - and capture the compiler's output as well? Hiya, This should help:- BMKFilePath on Windows defaults to C:\BlitzMax\bin\bmk.exe and ProjectFileName should be self explanatory. Last edited 2012 |
| ||
Thanks, col, I'll check it out! Russell p.s. I wonder why this is undocumented? Seems quite useful to me! (Makes me wonder what other gems are undocumented in there...) |
| ||
It compiles without errors, but doesn't do anything. :( Any ideas? Or maybe it would be better if someone could tell me where to find the bmk/bcc calling code in the BlitzMax IDE CE source? Thanks again, Russell |
| ||
ProjectFilename is the full path including the source filename with extension. |
| ||
Geez, I'm such an idiot: I didn't look it over as closely as I should have (didn't replace projectfilename, etc with valid values). And without 'Strict', the variables were given a default value of "". Anyway, this should do it. Thanks again (again!) Russell |