In this tutorial, you will find out how to create your own .mod.dat file that will allow you to use the Concatenation Script that I have previously scripted. You're probably reading this because you already know what the script is and are ready to use it, but if you don't know what it is check it out here: Concatenation Script Topic.

Moving on to the tutorial...

How to do it all!
    Step one, you must first create or open a blank file with the .mod.dat extension. Once opened and cleared of any content you must first know the simple rules of the .mod.dat files.
    Number 1 is that the first 4 lines are ignored. This space is for author definition and extra info about the mod the user is about to install/run. The next thing is that the first character of any line cannot contain a number sign (#). If you are needing to add a line with the (#) in it then put a space or tab before the first character of the line (#).

    Now that you know the only important rules you may know start learning about the .mod.dat syntax.

    First off, lets define the author information in our file and lets name our file MyModFile.mod.dat like so:
    Code:
    @@ @Author: Joseph Dalrymple;
    @@ @Date: January 29, 2008 at 12:23 AM;
    @@ @Desc: MyMod;
    @@ @Installs MyMod into MyFile;
    The way I did this is essential to identifying your mod. You MUST define the first four (4) lines like the example above. Swap out the different information like I did (note also that a trailing zero must prefix the day if it is a single digit).

    After defining your author information you can then start with your first function. This is pretty easy so far, right?

    Create a new file named MyFile.html and save it in the same directory as your .mod.dat and your install_mod.php files.

    After creating MyFile.html you many then add any type of content to it, and it doesn't have to be a .html file either. Heres an example of what I did:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
       <title>Untitled Document</title>
    <body>
    This is some txet.
    </body>
    </html>
    As you may know about the code I added: I have a spelling error on line 7 and I have a missing close <head> tag. To fix these problems I will use the Concatenation Script to patch this file up and keep the users who use it from having to dig through it and do it themselves. I'll then add two functions, an "add" function and a "replace" function to my MyModFile.mod.dat like so:
    Code:
    @@ @Author: Joseph Dalrymple;
    @@ @Date: January 29, 2008 at 12:23 AM;
    @@ @Desc: MyMod;
    @@ @Installs MyMod into MyFile;
    # MyFile.html 5 add
    </head>
    # MyFile.html 8 replace
    This is some text.
    Notice that after I had added a line to MyFile.html already that I had to adjust my second function to respect the previous update. Heres an example, the code in my MyFile.html was previously with out a </head> tag. But after I finished my first function the content was then changed and everything under the <title> tag was moved down therefore resulting it "This is some txet." to be moved down a space (from line 7 to line Cool. Hopefully this will only be a factor in the early versions and I'll be sure to work hard on keeping it nice and simple when it comes to what line to replace or add to.

    Now that we have our two functions to fix up our damaged MyFile.html script we're finished... right? Wrong. This is very important: after adding all the functions needed you MUST add the following line to the end of your file:

    Code:
    # EOF
    This tells my script that you don't have anymore functions to run and it will then gracefully end. So now our concluded code is:
    Code:
    @@ @Author: Joseph Dalrymple;
    @@ @Date: January 29, 2008 at 12:23 AM;
    @@ @Desc: MyMod;
    @@ @Installs MyMod into MyFile;
    # MyFile.html 5 add
    </head>
    # MyFile.html 8 replace
    This is some text.
    # EOF
This is, again, a lot easier then writing your own update or install script for your users and enables the ability to do various patching and installing.

    A recently added feature, SQL support, is very useful especially when installing or updating a DB dependent script. To add an SQL query to your file use the following syntax:
    Code:
    # sql SERVER USERNAME PASSWORD DATABASE
    Eventually I will add the requirement to enter this information through a form instead of in the mod file so that it is more portable.


If anyone has any questions or comments on this tutorial, please post them and I'll be more then happy to answer.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement