mpl
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
mpl [2016/07/11 16:21] – [WHILE] gryphon | mpl [2016/07/11 16:51] – gryphon | ||
---|---|---|---|
Line 208: | Line 208: | ||
==== PROCEDURES ==== | ==== PROCEDURES ==== | ||
+ | The syntax for defining a procedure is as follows: | ||
+ | |||
+ | Procedure <Proc Name> (< | ||
+ | <Code here> | ||
+ | |||
+ | IE: | ||
+ | |||
+ | Procedure Hello_World | ||
+ | WriteLn (' | ||
+ | |||
+ | OR: | ||
+ | |||
+ | Procedure SomeProc (Str String, A Byte) | ||
+ | WriteLn ('Str = ' + Str) | ||
+ | WriteLn (' | ||
+ | End | ||
+ | |||
+ | OR: | ||
+ | |||
+ | Procedure SomeProc (Str String) | ||
+ | Var | ||
+ | Str2 : String, | ||
+ | Str3 : String | ||
+ | Begin < | ||
+ | WriteLn (Str) just to maintain a " | ||
+ | End | ||
+ | ==== IF THEN/ | ||
+ | The syntax of an if/else/end statement: | ||
+ | |||
+ | If <boolean statement> | ||
+ | <True code here> | ||
+ | Else If <boolean statement> | ||
+ | <True code here> | ||
+ | Else (optional) | ||
+ | <False code here> | ||
+ | |||
+ | If Not fEof(fptr) Then | ||
+ | WriteLn (' | ||
+ | |||
+ | The above example is the same as the following example, except we've added an else statement: | ||
+ | |||
+ | If fEof(fptr) = False Then | ||
+ | WriteLn (' | ||
+ | Else | ||
+ | WriteLn ('This is the end of the file.' | ||
+ | |||
+ | |||
+ | If A = 1 Then | ||
+ | WriteLn ('A is 1') | ||
+ | Else If A = 2 Then | ||
+ | WriteLn ('A is 2') | ||
+ | Else If A = 5 Then | ||
+ | WriteLn ('A is 5') | ||
+ | Else | ||
+ | WriteLn ('A is not 1, 2, or 5...') | ||
+ | ==== CASE Statements ==== | ||
+ | |||
+ | This has actually been expanded on from the Pascal standard but still follows the same syntax. | ||
+ | |||
+ | Var I : Integer = 10 | ||
+ | | ||
+ | Case I Of | ||
+ | 1 : WriteLn(' | ||
+ | 2 : Begin | ||
+ | | ||
+ | | ||
+ | End | ||
+ | 3, | ||
+ | WriteLn(' | ||
+ | End | ||
+ | |||
+ | Var S : String = ' | ||
+ | Case S[3] Of | ||
+ | ' | ||
+ | ' | ||
+ | Else | ||
+ | | ||
+ | End | ||
+ | |||
+ | ==== FUNCTIONS ==== | ||
+ | The syntax for defining a function is as follows: | ||
+ | |||
+ | Function < | ||
+ | |||
+ | IE: | ||
+ | |||
+ | Function AddTen (Num Byte) : Byte | ||
+ | Begin | ||
+ | AddTen := Num + 10 | ||
+ | End | ||
+ | ==== CONST VARIABLES ==== | ||
+ | The syntax for a constant variable is as follows: | ||
+ | |||
+ | String constants: | ||
+ | |||
+ | Const | ||
+ | SomeStr = 'Hello World!' | ||
+ | |||
+ | Numerical constants: | ||
+ | |||
+ | Const | ||
+ | SomeNum = 69 | ||
+ | |||
+ | Constant variables, like regular variables, can be separated with a comma: | ||
+ | |||
+ | Const | ||
+ | SomeNum = 69, | ||
+ | SomeStr = 'Hello World!' | ||
+ | |||
+ | At the moment, constant variables cannot be used in certain places within the MPE engine. | ||
+ |
mpl.txt · Last modified: 2016/07/13 21:27 by g00r00