The Beginners Guide to MPE MPE2

What does it all mean?

Macro

This is the name of the Program.


VAR

This tells the computer all the Variable names, and what they are. For example, it now knows that 'Lastframe' is an INTEGER, but OK is boolean - i.e it is either TRUE or FALSE, and 'composite' is an IMAGE.

Our main types are INTEGER - just numbers. MPE has lots of different types,all listed in the Manual. If you don't assign a VAR to a variable, MPE assumes it is of type LONGINT.

You can generally give these variables any name, except those already taken by the system - like END or FOR or IMAGE, and names used as procedures & functions - more of them later.


BEGIN

Funnily enough, this is where the executable code begins! There is also an END.


(* Firstly... ... *)

This is a comment.
It is ignored, but its useful to remind you whats going on etc. Comments start with (* and end with *)


NumofImg.....

The first bit of real code.
We want to find out how many images there are in the splash. We use a FUNCTION called GETNUMBEROF- a little bit of pre-packaged code which returns a value into our variable called 'NumofImg'.
What type of variable is it? (Look under VAR).

All Functions return a value of a specific type i.e. INTEGER, BOOLEAN,REAL etc. In this case, it returns the number of images in the study - but, its very precise actually, it returns the number of images in study number 1, because we asked it to , using GETNUMBEROF (1,143) The 1 in brackets means Study number 1, and it returns the number of images because we used 143 which is the code for images, you can use mImage insted of 143, and most people do!

Now we could have returned the number of regions instead if we used the code for regions.

So, now NumofImg is actually the number of images in the study (study 1).


Some General points.

In MPE all lines end with a semicolon ;
All Procedure and functions arguments are in brackets.
White space is ignored - layout is only important for clarity.
Capitals have no effect.
Equals (more strictly "becomes") are represented by :=


Now a tricky bit.....

OK := GETINTEGER('FIRST FRAME? ',TRUE,{200,200},1,NumOfImg,Firstframe);


This next line is another Function, what it does is to ask the user for some input. Its called GETINTEGER and it does just that! Note how the equals sign is used, and notice that the function returns TRUE or FALSE to OK.
The arguments in brackets are seperated by commas - there are 6 of 'em!

  1. The text you want to display - in inverted commas. This is known as a string.
  2. Show a cancel button - yes or no - yes in this case
  3. Where on the screen you want the dialog box {200,200} - dont worry about this at present.
  4. Lowest number you can input - 1 is a good bet!
  5. Highest number you can input - the number of images which we just got
  6. What to store the input as - weve already told the program to expect Firstframe as an Integer in the VAR bit.

Complicated, but well worth it as you'll see later.


This is the result when you run it:

startframe image

 


If (not OK) then Stop();

If the user hits the OK button, the function returns the boolean value TRUE to the variable OK;
Cancel returns FALSE.

What this line does is to conditionally look at the value of OK, not OK is the same as OK being FALSE.
If that is so then the next instuction is carried out, if OK isn't FALSE, then the program skips to the next line.


Stop();

Stop() is a Procedure. This is the same as a function, except it doesn't return anything!
As you might have guessed, this procedure stops the program running.


Next page...

 

Last modified on: Wed, Jan 15, 1997.