Linking programs to other ones

BlitzMax Forums/BlitzMax Beginners Area/Linking programs to other ones

Zacho(Posted 2009) [#1]
Ok, I've looked over Include, Incbin, and couple other similar functions and am uncertain whether or not I could put multiple programs into one. I have a menu example (which I found on this site) which I'm thinking could put multiple programs into.

Menu:

So could I just put a Goto function in there to go and start the program if the user clicks enter or is there some other way this is accomplished.


Volker(Posted 2009) [#2]
I'm not sure what you want to do.
Start another compiled program, like .exe?
Then you could use
openurl "nameoffile.exe"

But linking compiled programs together is not possible with Blitzmax (except
mods).
You can split your sourcode over several files -> include.
Incbin is just for including binary files.
With goto you can just jump to a point in your sourcecode, not to
a point in a compiled file.
I would avoid goto as far as possible for the beginning.
Use functions and methods instead of goto.


Zacho(Posted 2009) [#3]
Well do you know when you build a .bmx file/code? I want a program to include different .bmx files and when you click on one, that one is loaded. I would maybe include it in the menu example up above, (I don't know how to though...)


Dabhand(Posted 2009) [#4]
Quick bit of p-code:-

Include "game1.bmx"
Include "game2.bmx"
include "game3.bmx"

local gameType:int = 2

select gameType
	case 1
		PlayGameOne()  'Located in the game1.bmx file
	case 2 
		PlayGameTwo()  'located in the game2.bmx file
	case 3
		PlayGameThree() ;located in the game3.bmx file
end select


Dabz


Zacho(Posted 2009) [#5]
Ok, but do you need
Local gameType:int = 2

Do you need the = 2 part

And also this part
select gameType
	case 1
		PlayGameOne()  'Located in the game1.bmx file
	case 2 
		PlayGameTwo()  'located in the game2.bmx file
	case 3
		PlayGameThree() ;located in the game3.bmx file
end select

PlayGameOne() isn't a function.


B(Posted 2009) [#6]
i think that you were supposed to create the functions yourself, and he was just giving you an outline.

notice how he said:

PlayGameOne()   'Located in the game1.bmx file


you are to have that function as the first game which you included as your other .bmx sourcecode files.


Zacho(Posted 2009) [#7]
Oh, so in my first .bmx file I would have the function named "PlayGameOne()" in the game loop, so when I call it, it plays that game. Gotcha!


Nate the Great(Posted 2009) [#8]
Zacho - basicly what the compiler does when you put include "yourfile.bmx" is its is copy and pasting that entire file you included right where the include line is. Now do you get it?


Zacho(Posted 2009) [#9]
Ya, I guess so