Problem building modules
BlitzMax Forums/BlitzMax Beginners Area/Problem building modules
| ||
Hello, I MinGW setup correctly (build modules is highlighted in editor) but when I try to build bots modules from his tutorial I am having a few problems. I have the module I want to build in the editor open, have saved it in a folder with the structure as bot suggest i.e bot.mod/firstmodule.mod/firstmodule.bmx and I select build module from the editor. All seems to go well and I get a process complete but then when I try to use the command from the module, in this case a simple SayHello("") function, I get a command not recognised error. Am I building the module in the wrong way? Do I have to use the command line (instead of the editors build option) and if so what should I be typing? Please could someone tell me what I am doing wrong as I am now a little lost. Thanks for your time, Jason. |
| ||
You probably need to import the module... something like:Import bot.firstmodule At the top of your code, should do the trick. |
| ||
OK Thanks, I`ll give it a try. I just assumed that once a module was built it was like part of the language from then on in otherwise you may as well just have it as a seperate source file right? Jason. |
| ||
only BRL and PUB modules are included by default nowadays (to cut down on program bloat). |
| ||
OK Cheers. Thanks for letting me know. So is there actually any benefit from making a module of your code over simply having your code in a seperate file that you include into your main code? Jason. |
| ||
So is there actually any benefit from making a module of your code Depends what you intend doing with it really. If you are planning on re-using it in multiple projects you'll find that a module is quite handy, since you only need to ... Import My.Module ... rather than give an exact path to the file to import. It's also pre-compiled, so you don't have to factor its compile-time into your application build. Modules are convenient :-) |
| ||
That explains things much better, thanks. All is clear now :) Jason. |
| ||
Also, modules have namespaces. So if you have two functions with the same name in different pieces of code, you can differentiate between them both by using the module namespace ahead of the function. |