MPL Training
Lesson 5
Black Panther

Our first program

Alright, enough with the basics. Let's get into some of the fun stuff. :) Now,
if any of you have taken any type of programming class, you know what the first
program you always write is, don't you?

Uses 
  User
  
Begin
  WriteLn('Hello World!')
End

There you go, we're done now, and you're on your own... I wouldn't really do 
that to you. ;)

So, we already talked about the Uses section, and went over the Begin/End. 
Let's take a closer look at the WriteLn function.

*BTW, I refer to all of these commands as functions. The reason for this, in
the libraries the compiler is using, these commands are actually names to 
functions which perform the operations you want them to. So, instead of having
to write your own functions, you can use the ones supplied.

There are two functions for printing text to the screen. They are the Write and
WriteLn functions. The only difference between them, is the WriteLn will insert
a newline at the end.

Begin
  WriteLn('Hello there.')
  WriteLn('How are you today?')
End

Will have the output of:

Hello there.
How are you today?

While:

Begin
  Write('Hello there.')
  Write('How are you today?')
End

Will output:

Hello there.How are you today?

Both of these are very useful, depending on the task you are working on. We'll 
go over some of the basics here.

These both take the same parameters.

Write(text)
WriteLn(text)

If you want to specify the text it should print, put inside of single quotes,
as you've seen in my other examples.

Write('Hello')

Also, if you want to print a single quote, just insert a second quote.

Write('I''m doing fine')

This way it will output:

I'm doing fine

You can also print the contents of a variable using these functions.

Var
  Text : String='Hello there'
Begin
  WriteLn(Text)
End

Output: Hello there

These functions are also used when writing information to a file. When doing 
this, you will need to have the file assigned and opened, which we'll get into
a bit later. To write a line to a text file, it would be:

WriteLn(fptr,'User messed up and entered the wrong command')

This would enter that line of text into the file, with the newline at the end.

When using this command in MPL, you can also include MCI display codes. So, if
you wanted to change the color or the text, you could type:

WriteLn('paulie is AWESOME!')

If this was written to a file, the line in the file would contain those MCI 
codes. This is handy if you will be reading those later to display to the 
screen.

While there are other options for writing text to the screen in MPL, we won't
go over all of them at this time. I will, however, let you know about another
write function that I've used. It's called WriteXY, and can be handy.

WriteXY(X,Y,Z:Byte;Str:String)

This will print the text to the location you specify, and in the color you 
specify. For example:

WriteXY(10,20,15,'Prints this text starting at 10,20, in White-15')

This can save you some lines of code, as you don't have to set the cursor 
position, and then write the text to the screen.

So,

GotoXY(10,20)
Write('Prints this text starting at 10,20, in White-15')

Becomes,

WriteXY(10,20,15,'Prints this text starting at 10,20, in White-15')

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

Input(Field:Byte,Max:Byte,Mode:Byte,Default:String):String

So, now you've printed text to the screen, and you want to get information from
the user. The Input function is the one you need. It takes parameters from you
which specify what type of input to accept, and gives you the users info.

The first parameter is the Field. This is the size of the input field that will
display on the screen. When you get to the logon screen for Mystic, it asks you
for your username, and you see the blue field after it. 

Secondly, you will tell it the Max, or maximum number of characters to accept
in this input. If the username variable will only hold 15 characters, you won't
want the user to try to enter in 20. With this set to 15, it will only take 
that many characters.

Next is the Mode. This is very nice, as you can only accept specific 
characters, or a specific format. Here is the list of options:

              1 : Standard input.  All characters allowed.
              2 : Upper case input.  Allows all characters, but will convert
                  any lower case letters into upper case.
              3 : Proper input.  Allows all characters, but will convert
                  the first letter in each word to an upper case letter.
              4 : Phone input.  Allows only numbers and will pre-format them
                  using the USA-style phone numbers.  IE: XXX-XXX-XXXX.
                  Note that the length of this input should always be 12,
                  as that is the length of the USA phone number format.
              5 : Date input.  Allows only numbers and will pre-format them
                  using the date format (ie XX/XX/XX) that is currently
                  selected by the user.  NOTE: The date input will always
                  return the date in the MM/DD/YY format, regardless of what
                  format the user has selected.  For example, if the user
                  has selected the DD/MM/YY format, Input will expect the
                  user to enter the date in that format, but will then
                  convert it to MM/DD/YY when it returns the date back to
                  the MPE program.
              6 : Password input.  Allows all characters, but will convert
                  any lower case letters into upper case.  The character
                  that is typed is NOT echoed to the screen.  Instead, it
                  is replaced by the * character so that what they have
                  entered will not be shown on the screen.
               7: Lowercase Allows characters but will be lowercase.
      	       8: User Defined Input (from system config)
               9: Standard Input with no CR
              10: Number Input numbers only and +-

So, if you only want number to be input, use mode 10, if you want date format,
use mode 5, etc.

Next, there is a default text that you can have appear in the input field. If
in your program, you have a form for the user to fill out, you can have the 
text of 'username' for example show in that field. It will be overwritten with
what the user types in.

Here is an example of how Input can be used:

Var
  UserName :String[15]
Begin
  UserName:=Input(15,15,1,'Enter UserName')
End

After that, your variable UserName, will have whatever the user typed into that
field.
