mpl
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| mpl [2016/07/11 15:24] – [General Notes About Using The MPL] gryphon | mpl [2016/07/13 21:27] (current) – g00r00 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Mystic Programming Language ====== | ====== Mystic Programming Language ====== | ||
| - | ===== General Notes About Using The MPL ===== | + | ===== General Notes About Using The MPL ===== |
| - | The syntax of the Mystic BBS Programming Language follows closely to | + | The syntax of the Mystic BBS Programming Language follows closely to |
| - | that of the Turbo Pascal series of programming compilers. | + | that of the Turbo Pascal series of programming compilers. |
| - | the language was almost 100% Turbo Pascal compatible (except for the | + | the language was almost 100% Turbo Pascal compatible (except for the |
| - | BBS functions) but it has been slightly changed to make it a little | + | BBS functions) but it has been slightly changed to make it a little |
| - | more friendly to the programmer. | + | more friendly to the programmer. |
| - | Two versions of the programming compiler are available in the scripts | + | Two versions of the programming compiler are available in the scripts |
| - | | + | directory. |
| - | | + | creating and compiling MPE programs. |
| - | Turbo Pascal IDE, including syntax highlighting of all command keywords! | + | Turbo Pascal IDE, including syntax highlighting of all command keywords! |
| - | The second version of the compiler is MPLC.EXE. | + | The second version of the compiler is MPLC.EXE. |
| - | | + | compiler supplied so you are not forced to use MIDE.EXE to write |
| - | | + | programs. |
| - | you can use your favorite text editor and MPLC.EXE to create programs! | + | you can use your favorite text editor and MPLC.EXE to create programs! |
| - | The following are some quick notes about the syntax of the language as | + | The following are some quick notes about the syntax of the language as |
| - | well as some notes about things that aren't working as they probably | + | well as some notes about things that aren't working as they probably |
| - | | + | should be: |
| - | - All text after a two slashes (⁄⁄) is considered a comment. | + | ==== Comments ==== |
| + | All text after a two slashes (⁄⁄) is considered a comment. | ||
| + | WriteLn (' | ||
| + | | ||
| + | ==== Operation types ==== | ||
| + | The MPL does not follow the order of operations when doing mathmatical equations (ie PEMDAS - parenthesis, | ||
| + | |||
| + | This doesn' | ||
| + | |||
| + | The following operation codes are supported for mathematical equations: | ||
| + | |||
| + | − Subtract | ||
| + | + Addition | ||
| + | * Multiplication | ||
| + | ⁄ Division | ||
| + | % Modulus Operator | ||
| + | | ||
| + | ==== Bitwise math ==== | ||
| + | MPL fully supports bitwise math and operators! | ||
| + | |||
| + | AND - Bitwise AND | ||
| + | OR - Bitwise OR | ||
| + | XOR - Bitwise exclusive OR | ||
| + | SHL - Bitwise shift left | ||
| + | SHR - Bitwise shift right | ||
| + | |||
| + | Example: | ||
| + | |||
| + | Const | ||
| + | UserDeleted = $00000004; | ||
| + | | ||
| + | Begin | ||
| + | GetThisUser; | ||
| + | | ||
| + | If UserFlags AND UserDeleted <> 0 Then | ||
| + | WriteLn(' | ||
| + | End; | ||
| + | |||
| + | ==== Defining Variables ==== | ||
| + | All variables are global to all of the program, including procedures. | ||
| + | |||
| + | Var < | ||
| + | | ||
| + | Examples: | ||
| + | | ||
| + | Var Dummy : Byte; | ||
| + | Var Str : String; | ||
| + | | ||
| + | Var | ||
| + | Dummy1, | ||
| + | Dummy2 | ||
| + | | ||
| + | The following variable types are supported: | ||
| + | |||
| + | Type Format | ||
| + | --------------- -------------- ---------------------------- | ||
| + | Boolean | ||
| + | Char Text 1 character | ||
| + | String | ||
| + | Byte Numerical | ||
| + | Integer | ||
| + | Word Numerical | ||
| + | LongInt | ||
| + | Cardinal | ||
| + | Real Numerical | ||
| + | |||
| + | All variables except ARRAYs can be initialized when when defined: | ||
| + | |||
| + | Var TotalBases : LongInt = GetMBaseTotal(False) | ||
| + | Var Int : Integer = 33 | ||
| + | Var Str : String = 'This is a string' | ||
| + | |||
| + | ARRAY multi-dimensional variables are supported. | ||
| + | |||
| + | Var < | ||
| + | Var < | ||
| + | Var < | ||
| + | |||
| + | Examples: | ||
| + | |||
| + | Var Dummy : Array[1..10] of Byte; | ||
| + | Var Str : Array[5..10] of String; | ||
| + | Var Int : Array[1..10, | ||
| + | |||
| + | HEXIDECIMAL values are supported. | ||
| + | |||
| + | Const | ||
| + | MyHexValue = $1F; | ||
| + | | ||
| + | Value := $10; | ||
| + | | ||
| + | If Value = $10 Then | ||
| + | WriteLn(' | ||
| + | |||
| + | ==== Record Structures ==== | ||
| + | |||
| + | Groups data in to records. | ||
| + | Defining the record: | ||
| + | |||
| + | Type | ||
| + | testrec = record | ||
| + | x : byte; | ||
| + | y : byte; | ||
| + | d : array[1..10, | ||
| + | end | ||
| + | |||
| + | Declaring the record: | ||
| + | |||
| + | Var struct : testrec | ||
| + | |||
| + | Using the record: | ||
| + | |||
| + | struct.x:=1 | ||
| + | struct.y: | ||
| + | struct.d[1, | ||
| + | WriteLn(struct.d[1, | ||
| + | WriteLn(' | ||
| + | ==== Code Blocks ==== | ||
| + | When using multiple lines (more than one line) within a IF/ | ||
| + | |||
| + | Examples: | ||
| + | If X = 1 Then | ||
| + | Begin | ||
| + | WriteLn(' | ||
| + | X:=X+1 | ||
| + | WriteLn(' | ||
| + | End | ||
| + | |||
| + | The same is true for the ELSE block. | ||
| + | |||
| + | If X = 1 Then | ||
| + | Begin | ||
| + | WriteLn(' | ||
| + | X:=X+1 | ||
| + | WriteLn(' | ||
| + | End | ||
| + | Else | ||
| + | Begin | ||
| + | WriteLn(' | ||
| + | X:=X-1 | ||
| + | WriteLn(' | ||
| + | End | ||
| + | | ||
| + | ==== FOR LOOPS ==== | ||
| + | The syntax for a for loop is as follows: | ||
| + | For < | ||
| + | |||
| + | For A := 1 to 10 Do | ||
| + | WriteLn (A) | ||
| + | | ||
| + | For A := 10 DownTo 1 Do | ||
| + | Begin | ||
| + | WriteLn (A) | ||
| + | WriteLn (A) | ||
| + | End | ||
| + | ==== REPEAT/ | ||
| + | The syntax for a repeat until loop is as follows: | ||
| + | |||
| + | Repeat | ||
| + | <Code here> | ||
| + | Until <Boolean Expression> | ||
| + | |||
| + | IE: | ||
| + | |||
| + | Repeat | ||
| + | WriteLn ('Blah blah') | ||
| + | Until A > 0 or A = 5 | ||
| + | ==== WHILE ==== | ||
| + | The syntax for a while loop is as follows: | ||
| + | |||
| + | While <Boolean Expression> | ||
| + | <Code Here> | ||
| + | |||
| + | IE: | ||
| + | |||
| + | While A > 0 and A = 5 Do | ||
| + | WriteLn (' | ||
| + | |||
| + | OR: | ||
| + | While A > 0 and A = 5 Do | ||
| + | Begin | ||
| + | WriteLn (' | ||
| + | WriteLn ('More Blah') | ||
| + | End | ||
| + | |||
| + | ==== 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.1468268640.txt.gz · Last modified: by gryphon
