MakeTree

Using MakeTree

1. What is MakeTree?

MakeTree is a small program that enables you to use the excellent Folder-Tree script by Marcelino Alves Martins without any knowledge of JavaScript - or programming! You simply start up your editor and define the layout of your tree. Then you call MakeTree and it will generate the proper JavaScript for you. It doesn't get any easier than this! Now download it!

2. Designing your Folder-Tree

The FolderTreeThe easiest way to design your Folder-Tree is to do it graphically. Just sit down, take a piece of paper and draw it. Which folders do I want and what should they contain. You might end up with something like on the right.

Yes, subfolders with no documents or other subfolders are allowed! In fact there are four types of subfolders:

  1. Empty subfolders
  2. Subfolders with subfolders
  3. Subfolders with documents
  4. Mixed subfolders, which contain documents as well as other subfolders

If you do create mixed subfolders, note that there are no subfolders allowed after documents. In other words, documents should come last. There is one other rule to observe. You may not "skip" a level and there should be a rootfolder at all times. The rootfolder is the main folder that contains all other folders.

3. Writing the ".mt" file (Version 1.x)

IMPORTANT!
If you are generating for Folder-Tree V2.x, you must skip both this step and the next! Please, continue with step 5.

In fact, designing your Folder-Tree is the hardest part. Now you got to lay it down in an ".mt" file, which is the file MakeTree uses. It is a simple ASCII file, which can be created with any editor. An ".mt" file contains three kinds of records:

  1. A rootrecord
  2. Folderrecords
  3. Documentrecords

4. A sample ".mt" file

0;Start folder;My homepage
.;Local docs
..;Profile
...;0;Personal info;ident.html
...;0;Resume;resume.html
..;Likes
...;0;Portugal;portugal.html
...;0;Books & Movies;arts.html
...;0;Photography;salgado.html
...;0;Music;musica.htm
.;Web favorites
..;Friends with sites
..;Reading
...;News
...;Cartoons
...;Science
...;Reference
...;Computers
...;1;Newsgroups;www.dejanews.com
...;1;Motorcycle;www.motorcycle.com
...;1;Agenda Cultural;portugal.hpv.pt/lisboa/agenda/
..;Searches
..;Sights & Sounds
..;Downloads
..;Shopping

Well, that doesn't look too hard does it? It is in essence an exact representation of the tree we've drawn above. We hope this will clarify what MakeTree actually expects.

5. Writing the ".mt2" file (Version 2.x)

IMPORTANT!
If you are generating for Folder-Tree V1.x, you must skip both this step and the next! Please, continue with step 7.

In fact, designing your Folder-Tree is the hardest part. Now you got to lay it down in an ".mt2" file, which is the file MakeTree uses. It is a simple ASCII file, which can be created with any editor. An ".mt2" file contains three kinds of records:

  1. A rootrecord
  2. Folderrecords
  3. Documentrecords

6. A sample ".mt2" file

Start folder;myhome.html
.;Local docs;local.html
..;Profile;profile.html
...;0;Personal info;ident.html
...;0;Resume;resume.html
..;Likes;likes.html
...;0;Portugal;portugal.html
...;0;Books & Movies;arts.html
...;0;Photography;salgado.html
...;0;Music;musica.htm
.;Web favorites;favorite.html
..;Friends with sites;friends.html
..;Reading;reading.html
...;News;news.html
...;Cartoons;cartoons.html
...;Science;science.html
...;Reference;refs.html
...;Computers;comp.html
...;1;Newsgroups;www.dejanews.com
...;1;Motorcycle;www.motorcycle.com
...;1;Agenda Cultural;portugal.hpv.pt/lisboa/agenda/
..;Searches;searches.html
..;Sights & Sounds;sights.html
..;Downloads;download.html
..;Shopping;shopping.html

Well, that doesn't look too hard does it? It is in essence an exact representation of the tree we've drawn above. We hope this will clarify what MakeTree actually expects.

7. Generating Folder-Tree

We assume that you have installed MakeTree according to the instructions. All you have to do now is run it. MakeTree was designed as an commandline utility, so it takes arguments. The first argument is always your ".mt" file. The second is the optional outputfile, e.g.:


maketree foldtree.mt

Will output the generated Folder-Tree V1.x program to the console (stdout). This one will create "index.htm" in the current directory:


maketree foldtree.mt index.htm

This one will create "photosturism.js" file for Folder-Tree V2.x in the current directory:


maketree -2 foldtree.mt2 photosturism.js

There are three options available, which you can add before the ".mt" file:

  1. -2: You MUST use this option if you want to generate a "photosturism.js" file for Folder-Tree V2.x! Otherwise, the program will assume you want a Folder-Tree V1.x compatible file.
  2. -b: This option is only available with MS Operating Systems. It will open the output file in binary mode, which will result in a Unix-compatible ASCII file.
  3. -d%c: This option will force the program to use character "%c" as a delimiter instead of a semi-colon.

8. Error messages

In order to help you find problems within your ".mt" or ".mt2" file, we have included the number of the offending line in the message. We have to stress that succesful generation does not always guarantee a useful Folder-Tree script. There are errors that MakeTree does not trap. If this happens, study the rules we've given carefully, take a look at our FAQ and if all fails, us. These are the messages MakeTree can generate: