ExecFile() Problem

Blitz3D Forums/Blitz3D Programming/ExecFile() Problem

Rogue Vector(Posted 2003) [#1]
My intro file is encapsulated in a seperate .exe file to my main game .exe file.

e.g.
Intro.exe ; run the intro sequence
Game.exe ; start the game engine etc

In Game.exe, I have the first line of code as:

ExecFile("Intro.exe")

It does launch the file, BUT, here's the problem - It doesn't wait until Intro.exe has finished executing before moving onto to the next line of code.

What I get is a glimpse of the intro then it is abruptly cut off and the main game engine starts up - overriding it.

Is there a way I can make the engine wait until the intro has finished playing before loading up the engine.

I don't really want to use a WaitKey() statement here.

I need the intro to smoothly feed into the game.

Thanks in advance
RV


soja(Posted 2003) [#2]
A batch file should work. Try this:

Create your batchfile go.bat (or go.cmd, if you want, and you have NT/XP)
Intro.exe
Game.exe


and then in your Blitz program:
ExecFile("cmd /c go.bat")


(You will have to use command.com instead of cmd.exe in 9x.)

Or, if you don't want a window popping up, try using CreateProcess instead of ExecFile, but I think it leaves a stream open which you have to close.


semar(Posted 2003) [#3]
Or just:
- run the 'intro' game
- at the end of the intro game, I mean inside the intro game code, just run the game itself.

In this way, there's no program who has to wait for another; just when the intro has finished, the last line before to quit will run the game itself.

So, to make a similar example like your one, in the Intro.exe, at the very end of the program put the statemet Execfile("Game.exe").

Hope it has sense for you,
Sergio.


JPL(Posted 2003) [#4]
.


Koriolis(Posted 2003) [#5]
@soja: This is not very suitable. It implies creating an exe (big) just to execute the bacth! If you use a batch, which seems fine for what you want, better directly say your entry point is the batch itself. Also note that you could directly do ExecFile("go.bat").
The nice method would indeed to use CreateProcess, but it exists only in BlitzPlus, not in Blitz3D :/

EDIT: just seen the post of semar, his method is just as easy indeed.


soja(Posted 2003) [#6]
This is not very suitable. It implies creating an exe (big) just to execute the bacth!


You're right -- duh! -- chalk that one up to being TOO FAR into the Blitz mindset! =)

...you could directly do ExecFile("go.bat").

Actually, you can't. It needs to be run from a command-line interpreter of some sort.


Koriolis(Posted 2003) [#7]
You can't? I must verify this, but I already done it!
Well maybe it didn't worked for you because the ".bat" files are not associated to cmd.exe nor command.com on your system?


Anthony Flack(Posted 2003) [#8]
To take the completely opposite standpoint, would it really be that difficult to merge the two into a single exe? It'll save you having to distribute all the blitz libraries twice over (once inside each exe), and therefore skim something like 600k off your download.

I can't think of any good reason why you wouldn't want both programs in one exe (feel free to enlighten me)


soja(Posted 2003) [#9]
Well maybe it didn't worked for you because the ".bat" files are not associated to cmd.exe nor command.com on your system?

Beats me. I've tried it on two different WinXP systems, and I haven't done anything funky with file associations... ?? I thought it was strange, but it DID work when I passed it as a parameter to cmd.exe... so I didn't think on it too much.


Rogue Vector(Posted 2003) [#10]
Okay.

You may be wondering why I want to do it this way.

Well... Basically, I've found a crude way of linking a Macromedia Flash Movie to a Blitz program.

My 'Intro.exe' file encapsulates a Macromedia Flash Title sequence overlayed onto embedded movie footage.

I can trigger the game.exe from the Flash executable, but I can't trigger the Flash executable from the Blitz program without the problem, previously descrided, occuring.

I think it would be cool if they could put something like a CreateProcess() into Blitz3D.

Cheers.

RV


soja(Posted 2003) [#11]
Well, I don't know anything about Flash, so I can't offer any suggestions there...

and if the straight "call a batch file" doesn't work for you...

then perhaps in game.exe, launch intro.exe, and then monitor for the existence of it using a userlib call (probably to some function in user32.dll or kernel32.dll), just looping on that until the program is terminated, then continue execution of game.exe once it's gone.

It just comes down to polling for termination instead of an event-based approach (I guess)


yinch(Posted 2003) [#12]
if you know the duration of your flash movie - maybe you could just stick a delay after the Execfile command. Probably with a polling loop to check if there has been a skip intro keypress

so for example
Execfile("intro.exe")
EndTime = MilliSecs() + DurationFlashMovieMS
While (MilliSecs() < EndTime)
    if (GetKey() <> 0) then EndTime = 0 ;detects key press
    Delay(40) ; this reduces CPU load
Wend

; continue with rest of your blitz program
; .
; .
; .


y'03