MPL Training
Lesson 1
Black Panther

What is MPL?

MPL stands for Mystic Programming Language. It is based off of Turbo Pascal,
but has been updated to closer resemble Free Pascal, which is still being 
developed today.

Here's what the Mystic Features says about MPL

MPL:
Built in programming language powerful enough for full blown games or simple 
modifications

Programs written with programming language work on all supported operating 
systems without changes

Programming language supports both PASCAL and INIQUITY/C style syntax

Command line compiler allows development with any source code editor

Built in source code editor with syntax highlighting, allows programs to be 
executed in the BBS and debugged from within the editor

Access many internal BBS functions with ease

Code is compiled, and can be distributed and usable with or without source code

No need to worry about I/O or BBS related functions in your programs. They 
accept multi-node messages, chat requests, etc without coding or worrying about 
it!

Unique access to remote screen images for client side pop up boxes, lists, 
screen save/restores even remote character/attribute plot access, user input, 
client side mouse support, etc!

-=-=-=-=-=-=-=-=-

MPL is actually a very powerful programming language, and there is so much that
it can do. Unfortunately, it seems there aren't many people left in the hobby
that use it.

How do I use MPL?

Included in your Mystic install, there are two programs. One is MPLC, which 
is the command line compiler for your MPL programs. You would just run it from
your main Mystic directory, and tell it where your source file is located. 
./mplc themes/default/scripts/example.mps
or
mplc themes\default\scripts\example.mps

When this finishes, you will either have a compiled example.mpx file, or it 
will tell you there was an error on line 5, for example. It will even tell you
what the problem was that it found. It makes it really easy to debug.

Another option, is using the MIDE program. This is an actual text editor that 
lets you compile directly from the editor. Either option works just fine, it's
more personal preference as to which you choose to use.

My personal choice, is to use an external editor. I use one on Linux, called
Geany, but there are many options out there for either Windows or Linux use.
I know that Notepad++ has many of the same features.

My reasoning, is I can tell Geany that I'm working on a Pascal file, and it 
will highlight keywords, color code strings, indicate if you are have a 'begin'
but no 'end', etc. I also have the ability to compile my code with MPLC without
having to leave Geany. Again, it's personal preference. Just find what you 
prefer to use.

-=-=-=-=-=-=-=-=-=-

So, how do I get started?

Ok, so you're ready to start typing in some code. Well, let's take a look at
a sample MPL program, and see what it consists of.

// Lines that begin with these two slashes are considered comments
// The compiler will completely ignore these lines
// It is a good idea to keep notes in your code as you type it
// When you look at your code later, you won't remember why you did things...

Uses
  User
  CFG

Var
  Age   : Byte
  Name  : String[20]
Begin
  WriteLn('What is your name?')
  Name:=Input(20,20,3,'')
  WriteLn('Hi '+Name+'! How old are you?')
  Age:=Input(2,2,10,'')
  WriteLn(Name+' are you really only '+Age+' years old?')
End

Alright. So this is a valid MPL program. I haven't actually compiled it, but it
should compile just fine. Let's take a look at the parts.

As stated above, the // indicates that line is a comment, and the compiler will
ignore those lines. If you have multiple lines of comments, you could always 
use (* and *) For example:

(*This is a multiple line comment, that will all be ignored when this program
is compiled. Remember to always comment your code, as you will need some type
of reminder when you look at your code later.*)

The next section indicates what should be included in this program. In this 
case, we are using both the User information and the CFG (Config) information.
When we have these, we can directly access both the user record, and many items
included within Mystic.

I haven't found a definitive list, but from what I've seen and heard, the 
following are all available for use via MPL:

User   - Users information
CFG    - Mystic Configuration
FBase  - Filebase Information
MBase  - Messagebase Information

The next section of the code indicates the variables that are being defined
globally. We'll get more into detail on this later, but these variables will be
available to use throughout the entire program.

The first word, is the name of your variable. Use something that will indicate
what the variable is used for. In our example, we named them 'Name' and 'Age', 
as that is what they are being used for. Don't get in the habit of using single
letters as variable names, as you won't remember what 'X' and 'Y' represent.

We then have the colon, which tells the compiler we will now be telling it what
type of variable these will be. In this case, one was a Byte, and the other was
a String. Again, we'll get more detail on those later.

The 'Begin' keyword tells the compiler that our program starts here. Every 
section of your code, will be between a set, or multiple sets, of 'Begin' and
'End' keywords.

Our program consists of asking the users name, and then his age, while printing
that information to the screen. Again, we'll go over the specifics of what 
these lines mean and what parameters are needed for them in a later lesson. 

In the next lesson, we'll get some information on the different variable types.
Don't worry, we'll have you writing programs pretty soon. There are just some
basics that I think should be gone over before we get to that point. :)
