This is the second of a three part article based on helping you making an application within MMF 1.5. In part one, I wrote about ways you can plan an application, extensions you can use, creating graphics, the active system box and designing your application interface. This part of the article will look more into the coding part of your application - such as implementing a open and save file system and using sub-apps within your games. I hope this part prooves useful to you.

Before you begin
Before you start coding, I think it is VERY useful to have your application designed first, and possibly even partly made within MMF. Implant your graphics into MMF, sort out where you want them to be. Then you can start the coding. It's important that you plan it out, and that it looks proffessional. If you haven't already, I suggest that you read Part 1 of these set of articles, which looks more into designing your application. To read it, click my name at the right and you can find a link on that page. To start off with, I shall continue to use my HTML editor application as an example throughout this article. However, the things you will learn shall probably be suitable for any application.

Open File System
This is the part of the application that, for some reason, I find extremely boring and sometimes a bit tricky. However, really it is rather simple.. For my example, I need to make it so that my application will allow the user to open a HTML document. When the user opens this document, the contents will be placed within my Rich edit object. To do this, you will need a button to click, the "File" object and a Rich Edit object.

1. Open MMF and create a "Open File" icon, which the user will click to open a new file. Also place a Rich edit object, and File object on the playfield.


2. Go straight to the event editor. Create a new condition, with the following events:

"Open File" Button is clicked
- Set file selector title to "Open File"
- Set file selector filters to ".HTML|*.html;*.htm"
- Open load file selector on ""

The first event simply sets the title of the load selector to "Open File". The second event makes it so that the user can only open files that end in the .html and .htm extensions. You can adapt this to have more extensions, simply by adding on a description and the appropriate extensions - e.g. ".HTML|*.html;*.htm"|.PHP|*.php|Text File|*.txt" .etc. The final event opens the load file selector.


3. On the same condition, under Rich Edit Object, add the following event:

- Load text FileSelReturn$( "File" )

You can find this under the "Load ASCII Text" event for the Rich Edit object. The calculation FileSelReturn$( "File" ) basically gives the pathname of the file that the user selected from the file selector above.


Although this is very basic, is works fine. If you want to, you could use the "Message Box and Asker" object, to open a message box asking if the user wants to save the current file before they open a new one. This would be a good idea - you can find the Message Box and Asker extension at


Save File System
Once you have done the open file system, you'll find the save file system a lot easier. It is virtually the same method, but obviously you save the file rather than open it. For this, you will need the same objects, plus a "Save File" button for the user to click.

1. Go to the event editor. Create a new condition with the following events:

"Save File" Button is clicked
- Set file selector title to "Save File"
- Set file selector filters to ".HTML|*.html;*.htm"
- Set default extension to ".html"
- Open save file selector on ""

These events are exactly the same as above, however they use the "Save" method rather than "load". However, you must set the default extension to ".html", or else your file will be saved with no extension at all.


2. On the same condition, under Rich Edit Object, add the following event:

- Save text FileSelReturn$( "File" )

That's self explanatory - and similar to the event when you load a text file (above). You obviously won't need to create a message box for this one, however you could use a "Save" and "Save As" feature. Where "Save" would save the file in it's current directory, and "Save As" would save the file in a new directory. For "save", you could just retrieve the current directory and use the same method to save the file. Simple!

New File System
Not sure why I am going to talk about this - mainly because it is very very simple! All you need to do, is either clear the "Rich Edit" object when a button is pressed, or delete the current Rich Edit object and create a new one. Again, it would be wise to ask the user if they would like to save their current file before opening a new one. This can be done using the message box and asker object. I will not going into how to use this object, because it is very self explanatory and easy to use anyway. Download it and check it out - its very useful.

TIP: If you decide to use the message box and asker, use a different Message Box object for each system. So a message box asker when the user opens a file, and another for when they make a new file. Don't make the mistake where I tried using one message box object for both systems - it gets messy and complicated and it's much easier just to use one for each system!

Example file
Although the above is VERY easy and basic stuff, I have made an example file as I know some of you are fussy. It's very easy to understand, so there are no comments within the file. You will need the extensions used above, and MMF 1.5 to view the below example file.

Sub-Applications and the GFO
I personally love using sub-applications, as they are a great way to implement other uses into your application. They are very easy to use once you know how, and for some reason I just have fun making and using them. But why use them in a HTML editor? Well you may not need them - however they are mainly good for creating "Wizards", which guides a user through something difficult. Sub-applications can also be used for the user to change certain options, or maybe even used as a side-menu within your application. To create a sub-app, simply goto Insert Object > Sub-Application.

Non-Popup Sub-Apps
These are simply sub-apps which don't pop up, and which are "built into" your application. This is mainly useful if you want to have a side menu within your application. See the image below:


The red area is your main application, while the yellow areas are the sub-apps. The top yellow area could be used to hold your "New, Open, Save File" buttons, and the right yellow area could be used to set options, or to insert HTML templates into the Rich Edit object. Why is this useful? Well although you don't necessarily need a sub-application for your new, open or save file icons, the yellow area on the right is very useful as the application within the sub app can change.

For example, at the start - the sub application could be called "insert.ccn". In this, the user can insert a template into the document. However, when clicking a button, the sub-app can be changed to "write.ccn" - where the user can write and create their own template. I'm not sure if I have explained this well enough, so I have created another example file for you:

This file is simply an application - when you click button 1, the sub-app switches to 1.ccn, and when you click button 2, the sub-app switches to 2.ccn. You can communicate between the sub-app and the main application, using the Global Function Object. This will be explained later on in the article.

Popup Sub-Apps
These are sub applications which open up in a new window. When this kind of sub-app is open, the user cannot interact with the main application until the sub application is closed. To create a popup sub application, simply tick the "Popup Window" box on the CCA Object Setup box. There are also many other options which you can apply to your sub application window, which you can see below:


Popup sub-apps are best used for "Wizards" or "Options/Settings" menus, where the user can change the settings of your application. Using popup sub-applications can make your application seem more proffessional, and can also proove to be very useful in some cases.

Filenames for sub-apps
On the CCA Object Setup box for your sub-app, you can only use .CCA and .CCN files within your sub-apps. The problem with this is that people get the source to your CCA file, or they can vitalize the CCN files and view them. I feel that the CCA and CCN extensions seem somewhat unproffessional for an application, so the best way is to cheat a little bit and disguise them as something else! I tend to disguise my CCN files as DLL files. This also makes the author look a little clever - as he/she has used a geeky little DLL file! Although somebody can simply change the extension back to CCN and view it - it does make it less obvious that its a CCN object.

To save a sub-app with any extension name, simply goto File > Build > Internet Application. Under "Save as type", select "All Files". Then type the file you want to save - e.g. insert.dll. If you don't select "All Files", you're sub-app will become "insert.dll.ccn". Although under the CCA Setup box you can only select CCA/CCN files, in the event editor you can use the following:

Start of level
- Set application to Appdrive$+ Appdir$ + "insert.dll"

Obviously, you don't have to use dll files. You could even make up your own extension - or if your boring stick with CCN. Using different extensions can also be useful - for example you could catergorize "Wizard sub-apps" with a .wiz extension and other files with other extensions. The possibilities are endless.

Global Function Object
I personally think that this extension is genius, and very useful indeed. You WILL need it whenever making a sub-application. It looks complicated, but it is very easy and you'll learn how to use it in no time! Firstly, you need to place a GFO within your main app. In the setup box for the GFO, untick "Use object name as target name" and type in a target name relating to your app.


I have used "main_app", but you can use anything at all. Basically, in my sub-app - when the use clicks a button, a function will be sent to an application with the name "main_app". Next, you need to create a GFO and put it within your sub-app. Leave the "Use object name as target name" box ticked. For this example, I shall send a function to my main app - so that when the user clicks a button, the main application ends. To do this, I will use the following condition and event in my sub-app:

Button is clicked
- Send function "end_app" within app to target "main_app"
- End the application (if sub-app is a popup)

This will send a function called "end_app" to my main application. If my sub-app is a popup, I want to close it using "End Application" after the function is sent. Now in the main app, I will use the following event:

On function "end_app"
- End the application

Simple! You can also send string and number arguments to your main application - simply by adding an argument before you send the function. The main app can then recieve the argument, and place it in a string or counter .etc. If you want to send a function from the main app to the sub app, you use the same method but send the function to the target name of the GFO in the sub-application. Hope you understand..

I understand if what I said in some parts was confusing - if you didn't understand something, or think I could have explained better (or if I've made a mistake), please tell me and I will happily edit the article.

In Part Three:-
- Using INI object for useful things
- More useful extensions to use
- Making sure your application is up to scratch
- Adding the finishing touches

Hope this helped - part three will be the final part to this set of articles. Thanks