How to understand and edit the savefile.

Savefiles are not binary data, but the structure might not be easy to understand for normal users. The savefiles consist of XML data and XML data is very strict about the format you use. The reason why we picked it is because it is a good format to store out data in, it's a recognized format and used on all platforms, there are also a lot of XML parsers out there making it easy for us to implement an error-free parser.

First open your savefile (it has the .xml extention) in a text viewer (notepad etc.). What do you see? It looks almost like HTML but just more confusing right? Don't worry it's actually really simple.
The savefile has a structure consisting of XML tags. The tags are nested in levels like HTML or folders on your harddisk. What i mean by that is, try and see the XML data as being containers of data each being able to hold more containers (just like a folder in a folder on your harddisk). The top level (like c: on your computer) is called <savefile> and the matching end-tag is called </savefile>. All your actions, aliases and substitutes are stored in matching nodes (like three different folders on your harddisk), called <aliases> <actions> and <substitutes> they all have matching end-tags called </aliases> </actions> and </substitutes>.

A simple demontrative example of a savefile would look like this:

<savefile>
  <aliases>
    ...
  </aliases>
  <actions>
    ...
  </actions>
  <substitutes>
    ...
  </substitutes>
</savefile>

The dots (...) represent more data, and that is what i'll explain now. For each node (like a folder on your computer) you can place more nodes and data. Let us take aliases for an example. The <aliases> node has subnodes each called alias. Notice that the subnode to <aliases> is <alias>. For <actions> the subnode is called <action> and for <substitutes> the subnode is <substitute>. Take a moment to reflect on that - the subnodes of each group has the same name, just in singular term. It makes sence if you think about it. <aliases> holds information about all aliases, and each of these aliases are called <alias>. The same goes for substitutes and actions.

Let us zoom in on the aliases part (leaving out the actions and substitutes in this example)

...
  <aliases>

    <alias name="basic/tar" format="plain">
      <% var("target") = $1 %>
    </alias>

    <alias name="basic/kt" format="plain">
      kill <% =var("target") %>
    </alias>

  </aliases>
...

As you can see, the aliases are all located as a subnode to the <aliases> node, and they are all called <alias>. They are recognized by the name "attribute". If you add another alias to your savefile, it will be added between the <aliases> and </aliases> tags just like the "basic/tar" and "basic/kt" aliases are. If you want to copy the "basic/tar" alias to a friend you just copy this part:

    <alias name="basic/tar" format="plain">
      <% var("target") = $1 %>
    </alias>

and he can add it to his own savefile.

In some cases, when you want to add something to an almost blank savefile (one that has no aliases, actions or subsitutes) you will see that there is no normal start of end-tag to the aliases, actions and substitute tags. This is because the XML parser will compact the nodes that are not in use. In that case you will see something like this:

<savefile>
  <aliases/>
  <actions/>
  <substitutes/>
...
</savefile>
As you can see the tags now END with the slash (/) and so the tag <aliases/> is different from BOTH <alises> and </aliases>. If you want to add an alias, there are no start and end tags to place it between. To fix this, you just add them youself - changing
  <aliases/>
to:
  <aliases>
    ...
  </aliases>
and place the aliases in the place where i left the dots (...).

I hope you understood this small tutorial on XML and how MonkeyTerm uses XML. I tried to keep it simple, but by doing that i have to leave out parts that you might feel are missing. If you want to understand MonkeyTerm's savefiles, brushing up on XML is a good idea, but for now this ought to be enough for everybody (didn't i hear that before?;).