Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MPL Documentation: Difference between revisions

From The Bottomless Abyss BBS Wiki
Created page with "   The Mystic BBS Programming Language Documentation    Copyright (C) 1998-2015 By James Coyle.  All Rights Reserved    All mentioned programs are copyrighted by thei..."
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
   The Mystic BBS Programming Language Documentation
The Mystic BBS Programming Language Documentation


   Copyright (C) 1998-2015 By James Coyle.  All Rights Reserved
Copyright (C) 1998-2015 By James Coyle.  All Rights Reserved


   All mentioned programs are copyrighted by their respective authors
All mentioned programs are copyrighted by their respective authors


   -----------------------------------------------------------------------
<nowiki>-----------------------------------------------------------------------</nowiki>


   Introduction to Mystic Programming Language (MPL)
''' Introduction to Mystic Programming Language (MPL) '''


   -----------------------------------------------------------------------
<nowiki>-----------------------------------------------------------------------</nowiki>


   The Mystic Programming Language (refered to as MPL from here on out) is
The Mystic Programming Language (refered to as MPL from here on out) is


   not complete.  In the state that it's in now, its still more powerful
not complete.  In the state that it's in now, its still more powerful


   than most BBS script languages, but its still not to the point where
than most BBS script languages, but its still not to the point where


   it is as powerful as it should be.
it is as powerful as it should be.


   The documentation for the MPL is also not complete.  This documentation


   as well as the Mystic BBS documentation will be worked on as time
The documentation for the MPL is also not complete.  This documentation


   permits and may not be completed for quite some time.  There are some
as well as the Mystic BBS documentation will be worked on as time


   example programs included with the distribution (found in the scripts
permits and may not be completed for quite some time.  There are some


   directory) which may help assist you in getting the hang of the MPL
example programs included with the distribution (found in the scripts


   structure and commands.
directory) which may help assist you in getting the hang of the MPL


   If you have written any useful MPL programs, please send them via e-mail
structure and commands.


   to [email protected] so they can be included for download on the


   various Mystic BBS support sites.
If you have written any useful MPL programs, please send them via e-mail


   -----------------------------------------------------------------------
to [email protected] so they can be included for download on the


   General Notes About Using The MPL
various Mystic BBS support sites.


   -----------------------------------------------------------------------
<nowiki>-----------------------------------------------------------------------</nowiki>


   The syntax of the Mystic BBS Programming Language follows closely to
''' General Notes About Using The MPL '''


   that of the Turbo Pascal series of programming compilers.  At one time,
<nowiki>-----------------------------------------------------------------------</nowiki>


   the language was almost 100% Turbo Pascal compatible (except for the
The syntax of the Mystic BBS Programming Language follows closely to


   BBS functions) but it has been slightly changed to make it a little
that of the Turbo Pascal series of programming compilers.  At one time,


   more friendly to the programmer.
the language was almost 100% Turbo Pascal compatible (except for the


   Two versions of the programming compiler are available in the scripts
BBS functions) but it has been slightly changed to make it a little


   directory.  The first one, MIDE.EXE, is a fully functional IDE for
more friendly to the programmer.


   creating and compiling MPE programs.  This program looks similar to the


   Turbo Pascal IDE, including syntax highlighting of all command keywords!
Two versions of the programming compiler are available in the scripts


   The second version of the compiler is MPLC.EXE.  This is a command line
directory.  The first one, MIDE.EXE, is a fully functional IDE for


   compiler supplied so you are not forced to use MIDE.EXE to write
creating and compiling MPE programs.  This program looks similar to the


   programs.  If you do not find the MIDE interface to be satisfactory, then
Turbo Pascal IDE, including syntax highlighting of all command keywords!


   you can use your favorite text editor and MPLC.EXE to create programs!
The second version of the compiler is MPLC.EXE.  This is a command line


   The following are some quick notes about the syntax of the language as
compiler supplied so you are not forced to use MIDE.EXE to write


   well as some notes about things that aren't working as they probably
programs.  If you do not find the MIDE interface to be satisfactory, then


   should be:
you can use your favorite text editor and MPLC.EXE to create programs!


   1.  All text after a number sign (#) is considered a comment.  It will
The following are some quick notes about the syntax of the language as


       be ignored until the next line of code.  For example:
well as some notes about things that aren't working as they probably


       WriteLn ('Hello There')  # This is a comment and will be ignored.
should be:


   2.  Operation types:


       The MPL does not follow the order of operations when doing
'''1.  All text after a number sign (#) is considered a comment.  It will '''
'''   be ignored until the next line of code.  For example: '''


       mathmatical equations (ie PEMDAS - parenthesis, exponents,
   WriteLn ('Hello There')  # This is a comment and will be ignored.


       multiplication, division, addition, subtraction)So math
''' 2Operation types: '''


       functions are done in the order that they appear in the expression.
   The MPL does not follow the order of operations when doing


       This doesn't mean its not POSSIBLE to do PEMDAS-ordered expressions,
   mathmatical equations (ie PEMDAS - parenthesis, exponents,


       it will just take a little more effort on the programmer's behalf.
   multiplication, division, addition, subtraction).  So math
   functions are done in the order that they appear in the expression.
   This doesn't mean its not POSSIBLE to do PEMDAS-ordered expressions,
   it will just take a little more effort on the programmer's behalf.
   The following operation codes are supported for mathmatical
   equations:


       The following operation codes are supported for mathmatical
       -   Subtract


       equations:
       +   Addition


               -   Subtract
       *   Multiplication


               +   Addition
       /   Division


               *   Multiplication
       %   Modulus Operator


               /   Division
''' 2a. Bitwise math: '''


               %   Modulus Operator
   MPL fully supports bitwise math and operators!  The following are
   implemented:


   2a. Bitwise math:
   AND - Bitwise AND


       MPL fully supports bitwise math and operators!  The following are
   OR  - Bitwise OR


       implemented:
   XOR - Bitwise exclusive OR


       AND - Bitwise AND
   SHL - Bitwise shift left


       OR  - Bitwise OR
   SHR - Bitwise shift right


       XOR - Bitwise exclusive OR
'''   Example: '''


       SHL - Bitwise shift left
   Const


       SHR - Bitwise shift right
   UserDeleted = $04;  // established bit for userdeleted from records.pas


       Example:
                       // note: this value has changed check records.pas!


       Const
   Begin


       UserDeleted = $04;  // established bit for userdeleted from records.pas
   GetThisUser


                           // note: this value has changed check records.pas!
   If UserFlags AND UserDeleted <> 0 Then


       Begin
    WriteLn('User is deleted');


       GetThisUser
   End;


       If UserFlags AND UserDeleted <> 0 Then
3.  Defining variables:  All variables are global to all of the program,


        WriteLn('User is deleted');
   including procedures.  The syntax for declaring a variable follows:


       End;
   Var <VarName> : <VarType>


   3.  Defining variables:  All variables are global to all of the program,
   Examples:


       including procedures.  The syntax for declaring a variable follows:
   var dummy : byte


       Var <VarName> : <VarType>
   var str   : string


       Examples:
   var


       var dummy : byte
     dummy : byte,


       var str   : string
     str   : string


       var
   The following variable types are supported:


         dummy : byte,
   Type            Format         Range


         str   : string
   --------------- -------------- -----------------------------------


       The following variable types are supported:
   Boolean         FALSE/TRUE     0..1


       Type            Format         Range
   Char            Text           1 character


       --------------- -------------- -----------------------------------
   String          Text           Sequence of 1..255 characters


       Boolean         FALSE/TRUE     0..1
   Byte            Numerical      0..255


       Char            Text           1 character
   Integer         Numerical      -32767..32767


       String          Text           Sequence of 1..255 characters
   Word            Numerical      0..65535


       Byte            Numerical      0..255
   LongInt         Numerical      -2147483648..214748364


       Integer         Numerical      -32767..32767
   Real            Numerical      9.99


       Word            Numerical      0..65535
   All variables exept ARRAYs can be initialized when when defined.


       LongInt         Numerical      -2147483648..214748364
   Var TotalBases : LongInt = GetMBaseTotal(False)


       Real            Numerical      9.99
   Var Int        : Integer = 33


       All variables exept ARRAYs can be initialized when when defined.
   Var Str        : String = 'This is a string'


       Var TotalBases : LongInt = GetMBaseTotal(False)
   ARRAY multi-dimensional variables are supported.  The syntax for


       Var Int        : Integer = 33
   declaring an array variable is:


       Var Str        : String = 'This is a string'
<nowiki>   Var <VarName> :  ARRAY[<Low>..<High>] of <VarType></nowiki>


       ARRAY multi-dimensional variables are supported.  The syntax for
<nowiki>   Var <VarName> :  ARRAY[<L>..<H>, <L>..<H>] of <VarType></nowiki>


       declaring an array variable is:
<nowiki>   Var <VarName> :  ARRAY[<L>..<H>, <L>..<H>, <L>..<H>] of <VarType></nowiki>


<nowiki>       Var <VarName> :  ARRAY[<Low>..<High>] of <VarType></nowiki>
'''   Examples: '''


<nowiki>       Var <VarName> :  ARRAY[<L>..<H>, <L>..<H>] of <VarType></nowiki>
<nowiki>   Var Dummy : Array[1..10] of Byte</nowiki>


<nowiki>       Var <VarName> :  ARRAY[<L>..<H>, <L>..<H>, <L>..<H>] of <VarType></nowiki>
<nowiki>   Var Str   : Array[5..10] of String</nowiki>


       Examples:
<nowiki>   Var Int   : Array[1..10,1..10,1..10] of Integer</nowiki>


<nowiki>       Var Dummy : Array[1..10] of Byte</nowiki>
   HEXIDECIMAL values are supported.  They can be used in numeric


<nowiki>       Var Str   : Array[5..10] of String</nowiki>
   variable assignment numerical evaluation, and in numeric constant


<nowiki>       Var Int   : Array[1..10,1..10,1..10] of Integer</nowiki>
   variables.  A hex value must begin with a $ character.  


       HEXIDECIMAL values are supported.  They can be used in numeric
   Some examples:


       variable assignment numerical evaluation, and in numeric constant
   Const


       variables.  A hex value must begin with a $ character.  
      MyHexValue = $1F;


       Some examples:
   Value := $10;


       Const
   If Value = $10 Then WriteLn('Value is 16 <in decimal>');


          MyHexValue = $1F;
''' 3b. Record structures:  '''


       Value := $10;
Groups data in to records.  This command


       If Value = $10 Then WriteLn('Value is 16 <in decimal>');
   allows you to create a datatype of multiple different variable


   3b. Record structures:  Groups data in to records.  This command
   types.


       allows you to create a datatype of multiple different variable
   Defining the record:


       types.
   Type


       Defining the record:
     testrec = record


       Type
     x : byte;


         testrec = record
     y : byte;


         x : byte;
<nowiki>     d : array[1..10,1..5] of string[9]</nowiki>


         y : byte;
   end


<nowiki>         d : array[1..10,1..5] of string[9]</nowiki>
   Declaring the record:


       end
       Var struct : testrec


       Declaring the record:
   Using the record:


           Var struct : testrec
       struct.x:=1


       Using the record:
       struct.y:=10


           struct.x:=1
       struct.d[1,1]:='abc123'


           struct.y:=10
   


           struct.d[1,1]:='abc123'
3c. CODE BLOCKS:  When using multiple lines (more than one line) within a


       
   IF/ELSE/WHILE/CASE blocks, the lines need to be grouped into


   3c. CODE BLOCKS:  When using multiple lines (more than one line) within a
   blocks between BEGIN and END statmentsIf there is only one line


       IF/ELSE/WHILE/CASE blocks, the lines need to be grouped into
   following the IF/ELSE/WHILE/CASE blocks, then no blocking statements


       blocks between BEGIN and END statments.  If there is only one line
   are needed.


       following the IF/ELSE/WHILE/CASE blocks, then no blocking statements
   Examples:


       are needed.
   


       Examples:
   If X = 1 Then


     
   Begin


       If X = 1 Then
      WriteLn('X = '+Int2Str(X))


       Begin
      X:=X+1


          WriteLn('X = '+Int2Str(X))
      WriteLn('X = '+Int2Str(X))


          X:=X+1
   End


          WriteLn('X = '+Int2Str(X))
   The same is true for the ELSE block.


       End
   If X = 1 Then


       The same is true for the ELSE block.
   Begin


       If X = 1 Then
      WriteLn('X = '+Int2Str(X))


       Begin
      X:=X+1


          WriteLn('X = '+Int2Str(X))
      WriteLn('X = '+Int2Str(X))


          X:=X+1
   End


          WriteLn('X = '+Int2Str(X))
   Else


       End
   Begin


       Else
      WriteLn('X = '+Int2Str(X))


       Begin
      X:=X-1


          WriteLn('X = '+Int2Str(X))
      WriteLn('X = '+Int2Str(X))


          X:=X-1
   End


          WriteLn('X = '+Int2Str(X))
4.  FOR LOOPS (FOR/FEND):  The syntax for a for loop is as follows:


       End
   For <variable> := <start number> <TO> or <DOWNTO> <end number> Do.  


   4.  FOR LOOPS (FOR/FEND):  The syntax for a for loop is as follows:
   For A := 1 to 10 Do


       For <variable> := <start number> <TO> or <DOWNTO> <end number> Do.  
        WriteLn (A)


       For A := 1 to 10 Do
   For A := 10 DownTo 1 Do  


            WriteLn (A)
   Begin


       For A := 10 DownTo 1 Do
        WriteLn (A)


       Begin
        WriteLn (A)


            WriteLn (A)
   End


            WriteLn (A)
5.  REPEAT/UNTIL:  The syntax for a repeat until loop is as follows:


       End
   Repeat


   5.  REPEAT/UNTIL:  The syntax for a repeat until loop is as follows:
        <nowiki><Code here></nowiki>


       Repeat
   Until <Boolean Expression>


            <nowiki><Code here></nowiki>
   IE:


       Until <Boolean Expression>
   Repeat


       IE:
        WriteLn ('Blah blah')


       Repeat
   Until A > 0 or A = 5


            WriteLn ('Blah blah')
6.  WHILE:  The syntax for a while loop is as follows:


       Until A > 0 or A = 5
   While <Boolean Expression> Do


   6.  WHILE:  The syntax for a while loop is as follows:
         <nowiki><Code Here></nowiki>


       While <Boolean Expression> Do
   IE:


             <nowiki><Code Here></nowiki>
   While A > 0 and A = 5 Do


       IE:
       WriteLn ('Blah')


       While A > 0 and A = 5 Do
   OR:


           WriteLn ('Blah')
   While A > 0 and A = 5 Do


       OR:
   Begin


       While A > 0 and A = 5 Do
       WriteLn ('Blah')


       Begin
       WriteLn ('More Blah')


           WriteLn ('Blah')
   End


           WriteLn ('More Blah')
7. PROCEDURES: The syntax for defining a procedure is as follows:


       End
  Procedure <Proc Name> (<varname vartype>, <varname vartype>)


   7. PROCEDURES: The syntax for defining a procedure is as follows:
    <nowiki><Code here></nowiki>


      Procedure <Proc Name> (<varname vartype>, <varname vartype>)
  IE:


        <nowiki><Code here></nowiki>
  Procedure Hello_World


      IE:
    WriteLn ('Hello World')


      Procedure Hello_World
  OR:


        WriteLn ('Hello World')
  Procedure SomeProc (Str String, A Byte)


      OR:
    WriteLn ('Str = ' + Str)


      Procedure SomeProc (Str String, A Byte)
    WriteLn ('A   = ' + A)


        WriteLn ('Str = ' + Str)
  End


        WriteLn ('A   = ' + A)
  OR:


      End
  Procedure SomeProc (Str String)


      OR:
  Var


      Procedure SomeProc (Str String)
    Str2 : String,


      Var
    Str3 : String


        Str2 : String,
  Begin             <--- The keyword "BEGIN" is ignored by the compiler           


        Str3 : String
    WriteLn (Str)        just to maintain a "Pascal-like" feel.


      Begin             <--- The keyword "BEGIN" is ignored by the compiler           
  End


        WriteLn (Str)        just to maintain a "Pascal-like" feel.
8. IF THEN/ELSE/END:  The syntax of an if/else/end statement:


      End
  If <boolean statement> Then


   8. IF THEN/ELSE/END:  The syntax of an if/else/end statement:
     <True code here>


      If <boolean statement> Then
  Else If <boolean statement> Then     (optional)


         <True code here>
     <True code here>


      Else If <boolean statement> Then     (optional)
  Else                            (optional)


         <True code here>
     <False code here>


      Else                            (optional)
  If Not fEof(fptr) Then


         <False code here>
       WriteLn (<nowiki>'We''re not at the end of the file.'</nowiki>)


      If Not fEof(fptr) Then
  The above example is the same as the following example, except we've


           WriteLn (<nowiki>'We''re not at the end of the file.'</nowiki>)
  added an else statement:


      The above example is the same as the following example, except we've
  If fEof(fptr) = False Then


      added an else statement:
       WriteLn (<nowiki>'We''re not at the end of the file.'</nowiki>)


      If fEof(fptr) = False Then
  Else


           WriteLn (<nowiki>'We''re not at the end of the file.'</nowiki>)
       WriteLn ('This is the end of the file.')


      Else
  If A = 1 Then


           WriteLn ('This is the end of the file.')
       WriteLn ('A is 1')


      If A = 1 Then
  Else If A = 2 Then


           WriteLn ('A is 1')
       WriteLn ('A is 2')


      Else If A = 2 Then
  Else If A = 5 Then


           WriteLn ('A is 2')
       WriteLn ('A is 5')


      Else If A = 5 Then
  Else


           WriteLn ('A is 5')
       WriteLn ('A is not 1, 2, or 5...')


      Else
8a. CASE statements


           WriteLn ('A is not 1, 2, or 5...')
   This has actually been expanded on


   8a. CASE statements
   from the Pascal standard but still follows the same syntax.  It has been


       This has actually been expanded on
   expanded to allow CASE of more variable types, such as strings.  See


       from the Pascal standard but still follows the same syntax.  It has been
   the included MPLTEST.MPS for examples.


       expanded to allow CASE of more variable types, such as strings.  See
   Var I : Integer = 10


       the included MPLTEST.MPS for examples.
   Case I Of


       Var I : Integer = 10
      1 : WriteLn('I = 1')


       Case I Of
      2 : Begin


          1 : WriteLn('I = 1')
            I:=I+1


          2 : Begin
            WriteLn('I = 3')


                I:=I+1
          End


                WriteLn('I = 3')
      2,3,4,5,6,7,8,9: WriteLn('Not 1, 2, or 10')


              End
   End


          2,3,4,5,6,7,8,9: WriteLn('Not 1, 2, or 10')
   Var S : String = 'ABCDEFG'


       End
   Case S[3] Of


       Var S : String = 'ABCDEFG'
      'A': WriteLn('S[3] = '+S[3])


       Case S[3] Of
      'B','C','D': WriteLn('S[3] = '+S[3])


          'A': WriteLn('S[3] = '+S[3])
   Else


          'B','C','D': WriteLn('S[3] = '+S[3])
      WriteLn('This is the default choice')


       Else
   End


          WriteLn('This is the default choice')
9.  The USES command must be declared before ANY other variables


       End
   or your program may not function properly.  See documentation for


   9.  The USES command must be declared before ANY other variables
   the USES command for further information.


       or your program may not function properly.  See documentation for
10. FUNCTIONS: The syntax for defining a function is as follows:


       the USES command for further information.
   Function <Function Name> (<varname vartype>) : <result type>


   10. FUNCTIONS: The syntax for defining a function is as follows:
   IE:


       Function <Function Name> (<varname vartype>) : <result type>
   Function AddTen (Num Byte) : Byte


       IE:
   Begin


       Function AddTen (Num Byte) : Byte
     AddTen := Num + 10


       Begin
   End


         AddTen := Num + 10
11. CONST VARIABLES: The syntax for a constant variable is as follows:


       End
   String constants:
 
   11. CONST VARIABLES: The syntax for a constant variable is as follows:


       String constants:
   Const


       Const
     SomeStr = 'Hello World!'


         SomeStr = 'Hello World!'
   Numerical constants:


       Numerical constants:
   Const


       Const
     SomeNum = 69


         SomeNum = 69
   Constant variables, like regular variables, can be separated with a


       Constant variables, like regular variables, can be separated with a
   comma:


       comma:
   Const


       Const
     SomeNum = 69,


         SomeNum = 69,
     SomeStr = 'Hello World!'


         SomeStr = 'Hello World!'
   At the moment, constant variables cannot be used in certain places


       At the moment, constant variables cannot be used in certain places
   within the MPE engine.  If you are assigning a value to a variable,


       within the MPE engine.  If you are assigning a value to a variable,
   constant values will not be recongnized.


       constant values will not be recongnized.
<nowiki>-----------------------------------------------------------------------</nowiki>


   -----------------------------------------------------------------------
General Functions and Procedures


   General Functions and Procedures
<nowiki>-----------------------------------------------------------------------</nowiki>


   -----------------------------------------------------------------------
Function ABS (Num: LongInt) : LongInt


   Function ABS (Num: LongInt) : LongInt
   This function takes a signed integer and returns the absolute value.


       This function takes a signed integer and returns the absolute value.
   Example:


       Example:
   Var Int : LongInt = -1234


       Var Int : LongInt = -1234
   WriteLn('The absolute value of '+Int2str(Int) +' is '+Abs(Int)+'.')


       WriteLn('The absolute value of '+Int2str(Int) +' is '+Abs(Int)+'.')
Function ALLOWARROW (Boolean)


   
   


   Function ALLOWARROW (Boolean)
   Used to turn on arrow key processing in the READKEY function.  It is


       
   also used outside of MPL so use with caution.


       Used to turn on arrow key processing in the READKEY function.  It is
   Example:


       also used outside of MPL so use with caution.
   AllowArrow := True


       Example:
   ReadKey


       AllowArrow := True
Variable ALLOWMCI (boolean)


       ReadKey
   This function toggles on/off MCI code parsing.  This is used outside of


   Variable ALLOWMCI (boolean)
   MPL so adjust this with caution.


       This function toggles on/off MCI code parsingThis is used outside of
Procedure APPENDTEXT (FileName, Text: String).  


       MPL so adjust this with caution.
   This procedure will append a single line of text onto a text file.  If


   Procedure APPENDTEXT (FileName, Text: String).  
   the file does not exist, it will be createdExample:


       This procedure will append a single line of text onto a text file.  If
Function BITCHECK (B : Byte; I : Integer) : Boolean


       the file does not exist, it will be created.  Example:
   This function accepts a bit position and checks it against an integer,


   Function BITCHECK (B : Byte; I : Integer) : Boolean
   returning true or false if the bit is on.  So for example in the


       This function accepts a bit position and checks it against an integer,
   Records, the third bit in UserFlags is UserDeleted:


       returning true or false if the bit is on.  So for example in the
   GetThisUser


       Records, the third bit in UserFlags is UserDeleted:
   If BitCheck(3, UserFlags) Then WriteLn('User is marked deleted');


       GetThisUser
Procedure  BITSET (B : Byte; I : Integer)


       If BitCheck(3, UserFlags) Then WriteLn('User is marked deleted');
   This procedure accepts a bit position and an integer and sets the


   Procedure  BITSET (B : Byte; I : Integer)
   bit ON/OFF based on a boolean:


       This procedure accepts a bit position and an integer and sets the
   GetThisUser


       bit ON/OFF based on a boolean:
   BitSet(3, UserFlags, True);  // user is marked as deleted


       GetThisUser
Procedure BITTOGGLE (B : Byte; I : Integer)


       BitSet(3, UserFlags, True);  // user is marked as deleted
   This procedure accepts a bit position and an integer and toggles the


   Procedure BITTOGGLE (B : Byte; I : Integer)
   bit.


       This procedure accepts a bit position and an integer and toggles the
   GetThisUser


       bit.
   BitToggle(3, UserFlags);  // undeletes if they are deleted or deletes if


       GetThisUser
                             // they are not deleted.


       BitToggle(3, UserFlags);  // undeletes if they are deleted or deletes if
Variables CFGCHATSTART CFGCHATEND.  


                                 // they are not deleted.
   These return the byte of the chat hour start and end variables from the


   Variables CFGCHATSTART CFGCHATEND.  
   System Configuration


       These return the byte of the chat hour start and end variables from the
Procedure CLRSCR


       System Configuration
    This function will clear the screen.


   Procedure CLRSCR
    Example:


        This function will clear the screen.
    CLRSCR


        Example:
    Writeln ('The screen was just cleared.')


        CLRSCR
    The above function will clear the screen and write the text "The


        Writeln ('The screen was just cleared.')
    screen was just cleared." to the screen.


        The above function will clear the screen and write the text "The
Function DATE2DOS (Str : String) : LongInt


        screen was just cleared." to the screen.
    This function takes a MM/DD/YY format date and converts it to


   Function DATE2DOS (Str : String) : LongInt
    DOS packed datetime format.


        This function takes a MM/DD/YY format date and converts it to
    Var DStr : String = '01/01/14'


        DOS packed datetime format.
    Var PDt  : LongInt


        Var DStr : String = '01/01/14'
    PDt := Date2Dos(DStr)


        Var PDt  : LongInt
Function DATE2JULIAN (Str : String) : LongInt


        PDt := Date2Dos(DStr)
    This function takes a MM/DD/YY format date and converts it to a


   Function DATE2JULIAN (Str : String) : LongInt
    Julian date format.


        This function takes a MM/DD/YY format date and converts it to a
Function DATEG2J (Str : String) : LongInt


        Julian date format.
    This function takes a gregorian date format (MMDDYY) and converts


   Function DATEG2J (Str : String) : LongInt
    it to a Julian format


        This function takes a gregorian date format (MMDDYY) and converts
Function DATEJ2G (LI : LongInt) : String


        it to a Julian format
    This function takes a julian date format and converts it to a


   Function DATEJ2G (LI : LongInt) : String
    gregorian format (MMDDYY).


        This function takes a julian date format and converts it to a
Function DATEJULIAN : LongInt


        gregorian format (MMDDYY).
    This function returns the Julian value of the current date.


   Function DATEJULIAN : LongInt
Function DATESTRJULIAN (JD : LongInt) : String


        This function returns the Julian value of the current date.
    This function returns the MM/DD/YY string value of the julian date.


   Function DATESTRJULIAN (JD : LongInt) : String
Function DATEVALID (Str : String) : Boolean


        This function returns the MM/DD/YY string value of the julian date.
    This function takes a MM/DD/YY date and returns true or false


   Function DATEVALID (Str : String) : Boolean
    depending on if the date is valid (ie, month is 01-12, etc).


        This function takes a MM/DD/YY date and returns true or false
Function DAYOFTHEWEEK


        depending on if the date is valid (ie, month is 01-12, etc).
    Returns a number between 0-6 depending on the day of the week:


   Function DAYOFTHEWEEK
    0 = Sun, 1 = Mon, 2 = Tue, 3 = Wed, 4 = Thu, 5 = Fri, 6 = Sat


        Returns a number between 0-6 depending on the day of the week:
Function DAYSAGO (JD : LongInt) : Integer


        0 = Sun, 1 = Mon, 2 = Tue, 3 = Wed, 4 = Thu, 5 = Fri, 6 = Sat
    This function takes the Julian date value and returns the number


   Function DAYSAGO (JD : LongInt) : Integer
    of days between the current date and the passed date.


        This function takes the Julian date value and returns the number
Function DAYOFWEEK : Integer


        of days between the current date and the passed date.
    This function will return a number between 0-6 depending on the


   Function DAYOFWEEK : Integer
    day of the week:


        This function will return a number between 0-6 depending on the
    0 = Sun, 1 = Mon, 2 = Tue, 3 = Wed, 4 = Thu, 5 = Fri, 6 = Sat


        day of the week:
Procedure DELAY (MS: Word)


        0 = Sun, 1 = Mon, 2 = Tue, 3 = Wed, 4 = Thu, 5 = Fri, 6 = Sat
    This procedure will delay for a specified number of milliseconds.


   Procedure DELAY (MS: Word)
    Example:


        This procedure will delay for a specified number of milliseconds.
    DELAY (1000)


        Example:
    The above example will delay the program for one second.


        DELAY (1000)
Function DOSERROR : Byte


        The above example will delay the program for one second.
    This function returns the current DosError and is used with the


   Function DOSERROR : Byte
    FindFirst and FindNext functions.  The possible values which may


        This function returns the current DosError and is used with the
    be returned by DosError are as follows:


        FindFirst and FindNext functions.  The possible values which may
    Value  Meaning


        be returned by DosError are as follows:
    -----  ---------------------


        Value  Meaning
      0    No error


        -----  ---------------------
      2    File not found


          0    No error
      3    Path not found


          2    File not found
      5    Access denied


          3    Path not found
      6    Invalid handle


          5    Access denied
      8    Not enough memory


          6    Invalid handle
     10    Invalid environment


          8    Not enough memory
     11    Invalid format


         10    Invalid environment
     18    No more files


         11    Invalid format
    -----  ---------------------


         18    No more files
    Example:


        -----  ---------------------
    FindFirst ('*.*', AnyFile)


        Example:
    While DosError = 0 Do Begin


        FindFirst ('*.*', AnyFile)
         WriteLn ('File Name: ', DirName)


        While DosError = 0 Do Begin
         FindNext


             WriteLn ('File Name: ', DirName)
    End


             FindNext
    FindClose                


        End
    The above example will list all files in the current directory.


        FindClose                
    The DosError function is used to return when there are no more


        The above example will list all files in the current directory.
    files to be listed.  For more information on this see the reference


        The DosError function is used to return when there are no more
    for the FindFirst and FindNext functions.


        files to be listed.  For more information on this see the reference
Procedure FINDCLOSE


        for the FindFirst and FindNext functions.
    This function is used along with the FindFirst and FindNext


   Procedure FINDCLOSE
    functions.  It is called only after all "Find" procedures have


        This function is used along with the FindFirst and FindNext
    completed.  See the "FindFirst" and "FindNext" command references


        functions.  It is called only after all "Find" procedures have
    for more information.


        completed.  See the "FindFirst" and "FindNext" command references
Procedure FINDFIRST (Mask : String, Attributes)


        for more information.
    This function is used to search a drive for files using a supplied


   Procedure FINDFIRST (Mask : String, Attributes)
    file mask and attribute list.  The results of the search are held


        This function is used to search a drive for files using a supplied
    in the DIR variables as listed below.


        file mask and attribute list.  The results of the search are held
    Mask : The mask variable must contain at least a file mask


        in the DIR variables as listed below.
           (ie "*.*") but can also contain a drive and directory name


        Mask : The mask variable must contain at least a file mask
           as well (ie "C:\MYSTIC\TEXT\*.*").


               (ie "*.*") but can also contain a drive and directory name
    Attributes : The file attributes are used to specify what type of


               as well (ie "C:\MYSTIC\TEXT\*.*").
                 files to return in the DIR variables.  The following


        Attributes : The file attributes are used to specify what type of
                 is a list of supported file attributes:


                     files to return in the DIR variables.  The following
                 Dec Description Returns


                     is a list of supported file attributes:
                 --- ----------- -----------------


                     Dec Description Returns
                 001 ReadOnly    files marked as "read only".


                     --- ----------- -----------------
                 002 Hidden      files marked as "hidden".


                     001 ReadOnly    files marked as "read only".
                 004 SysFile     files marked as "system files".


                     002 Hidden      files marked as "hidden".
                 008 VolumeID    files marked as "volume ID".


                     004 SysFile     files marked as "system files".
                 016 Directory   files marked as "directory".


                     008 VolumeID    files marked as "volume ID".
                 032 Archive     files marked as "archive".


                     016 Directory   files marked as "directory".
                 066 AnyFile     any and all files.


                     032 Archive     files marked as "archive".
                 These attributes can be combined when passed to


                     066 AnyFile     any and all files.
                 FindFirst.  For example: 1 + 2 will return


                     These attributes can be combined when passed to
                 any files which have been marked as "readonly" OR


                     FindFirstFor example: 1 + 2 will return
                 "hidden"Example: 16 (DIRECTORY) will only return names


                     any files which have been marked as "readonly" OR
                 of directories.


                     "hidden".  Example: 16 (DIRECTORY) will only return names
    DIR Variables : The DIR variables are what contain the information


                     of directories.
                    returned by the FindFirst command.  If your program


        DIR Variables : The DIR variables are what contain the information
                    is going to use these variables, it must be declared


                        returned by the FindFirst command.  If your program
                    with the USES statement at the beginning of your


                        is going to use these variables, it must be declared
                    program source code.  The following DIR variables


                        with the USES statement at the beginning of your
                    are supported:


                        program source code.  The following DIR variables
                    DirName : Holds the file name.


                        are supported:
                    DirSize : Holds the file size.


                        DirName : Holds the file name.
                    DirAttr : Holds the file attributes


                        DirSize : Holds the file size.
                    DirTime : Holds the file date and time in packed


                        DirAttr : Holds the file attributes
                              date format.  The DateSTR and TimeSTR


                        DirTime : Holds the file date and time in packed
                              functions will need to be used in order


                                  date format.  The DateSTR and TimeSTR
                              to display these.


                                  functions will need to be used in order
    Example:


                                  to display these.
    USES DIR


        Example:
    WriteLn ('The following files are in the C:\ directory:')


        USES DIR
    WriteLn (<nowiki>''</nowiki>)


        WriteLn ('The following files are in the C:\ directory:')
    FindFirst ('C:\*.*', 66)


        WriteLn (<nowiki>''</nowiki>)
    While DosError = 0 Do


        FindFirst ('C:\*.*', 66)
    Begin


        While DosError = 0 Do
         WriteLn ('File Name: ', DirName)


        Begin
         WriteLn ('     Size: ', DirSize)


             WriteLn ('File Name: ', DirName)
         WriteLn ('     Date: ', DateSTR(DirTime), 0)


             WriteLn ('     Size: ', DirSize)
         WriteLn ('     Time: ', TimeSTR(DirTime), 1)


             WriteLn ('     Date: ', DateSTR(DirTime), 0)
         Write   ('Press a key to search for more.~PN')


             WriteLn ('     Time: ', TimeSTR(DirTime), 1)
         FindNext


             Write   ('Press a key to search for more.~PN')
    End


             FindNext
    FindClose


        End
    WriteLn ('No more files have been found.')


        FindClose
    The above example will list all files which fit the file mask of


        WriteLn ('No more files have been found.')
    "C:\*.*" and fit the attributes of either ReadOnly or Archive.


        The above example will list all files which fit the file mask of
    The DOSERROR function is used to determine when there are no more


        "C:\*.*" and fit the attributes of either ReadOnly or Archive.
    files found (See the DOSERROR reference).  If a file has been


        The DOSERROR function is used to determine when there are no more
    found, it will then be printed to the screen using the DIR


        files found (See the DOSERROR reference).  If a file has been
    variables.  The FindNext functon is used to find the next file


        found, it will then be printed to the screen using the DIR
    that matches the name and attributes specified in the earlier call


        variablesThe FindNext functon is used to find the next file
    to FindFirstFindClose is used when all "Find" functions have been


        that matches the name and attributes specified in the earlier call
    completed.


        to FindFirst.  FindClose is used when all "Find" functions have been
Procedure FINDNEXT


        completed.
    This procedure is used to find the next file which matches the file


   Procedure FINDNEXT
    mask and attibutes specified in the last call to FindFirst.


        This procedure is used to find the next file which matches the file
    Example:


        mask and attibutes specified in the last call to FindFirst.
    Uses DIR


        Example:
    FindFirst ('*.*', 32)


        Uses DIR
    While DosError = 0 Do


        FindFirst ('*.*', 32)
    Begin


        While DosError = 0 Do
         WriteLn ('File Name: ', DirName)


        Begin
         FindNext


             WriteLn ('File Name: ', DirName)
    End


             FindNext
    FindClose


        End
    The above example uses the FindFirst/FindNext functions to do a


        FindClose
    listing of all files in the current directory.  The DosError


        The above example uses the FindFirst/FindNext functions to do a
    function is used to determine when no more files have been found.


        listing of all files in the current directory.  The DosError
Procedure GOTOXY (X: Byte, Y: Byte)


        function is used to determine when no more files have been found.
    This procedure will move the cursor to a specified X and Y


   Procedure GOTOXY (X: Byte, Y: Byte)
    position on the screen.  This only works for users who have ANSI


        This procedure will move the cursor to a specified X and Y
    graphics.


        position on the screen.  This only works for users who have ANSI
    Example:


        graphics.
    CLRSCR


        Example:
    GotoXY (1, 10)


        CLRSCR
    WriteLn ('Hello')


        GotoXY (1, 10)
    The above example will clear the screen then goto the first column


        WriteLn ('Hello')
    of the tenth line and output the text "Hello" to the screen.


        The above example will clear the screen then goto the first column
Procedure HALT


        of the tenth line and output the text "Hello" to the screen.
    This procedure will exit the program and return the user back to


   Procedure HALT
    the BBS immediately.


        This procedure will exit the program and return the user back to
    Example:


        the BBS immediately.
    If Graphics = 0 Do


        Example:
    Begin


        If Graphics = 0 Do
         WriteLn ('Sorry, you do not have ANSI graphics.')


        Begin
         Halt


             WriteLn ('Sorry, you do not have ANSI graphics.')
    End


             Halt
    The above example will check to see if the user has ANSI graphics


        End
    and if not, display "Sorry, you do not have ANSI" and exit the


        The above example will check to see if the user has ANSI graphics
    program immediately by using the HALT command.


        and if not, display "Sorry, you do not have ANSI" and exit the
Function INITIALS (String) : String


        program immediately by using the HALT command.
    This function takes a user name and attempts to return one or two


   Function INITIALS (String) : String
    character initials.


   
    S := Initials('Jack Phlash'); // should return "JP"


        This function takes a user name and attempts to return one or two
Function INPUT (Field: Byte, Max: Byte, Mode: Byte, Default: String) : String


        character initials.
    This function gives input to the user, and returns the result of


        S := Initials('Jack Phlash'); // should return "JP"
    the input as a string variable.


   Function INPUT (Field: Byte, Max: Byte, Mode: Byte, Default: String) : String
    The Field parameter is the size of the input field (in characters)


        This function gives input to the user, and returns the result of
    that the user will be able to see.  If the field size is smaller


        the input as a string variable.
    than the maximum number of characters allowed in the input, the


        The Field parameter is the size of the input field (in characters)
    input line will scroll when the user reaches the end.  This field


        that the user will be able to see.  If the field size is smaller
    is usually set to the same as the Max parameter.


        than the maximum number of characters allowed in the input, the
    The Max parameter is the maximum number of characters that


        input line will scroll when the user reaches the endThis field
    Input will allow to be enteredNote that the Field parameter, in


        is usually set to the same as the Max parameter.
    most cases, should be set to the same value as this.


        The Max parameter is the maximum number of characters that
    The Mode parameter is the type of input that will be accepted, and


        Input will allow to be entered.  Note that the Field parameter, in
    can be any one of the following input types:


        most cases, should be set to the same value as this.
         1 : Standard input.  All characters allowed.


        The Mode parameter is the type of input that will be accepted, and
         2 : Upper case input.  Allows all characters, but will convert


        can be any one of the following input types:
             any lower case letters into upper case.


             1 : Standard input.  All characters allowed.
         3 : Proper input.  Allows all characters, but will convert


             2 : Upper case input.  Allows all characters, but will convert
             the first letter in each word to an upper case letter.


                 any lower case letters into upper case.
         4 : Phone input.  Allows only numbers and will pre-format them


             3 : Proper input.  Allows all characters, but will convert
             using the USA-style phone numbers.  IE: XXX-XXX-XXXX.


                 the first letter in each word to an upper case letter.
             Note that the length of this input should always be 12,


             4 : Phone input.  Allows only numbers and will pre-format them
             as that is the length of the USA phone number format.


                 using the USA-style phone numbersIE: XXX-XXX-XXXX.
         5 : Date inputAllows only numbers and will pre-format them


                 Note that the length of this input should always be 12,
             using the date format (ie XX/XX/XX) that is currently


                 as that is the length of the USA phone number format.
             selected by the user.  NOTE: The date input will always


             5 : Date input.  Allows only numbers and will pre-format them
             return the date in the MM/DD/YY format, regardless of what


                 using the date format (ie XX/XX/XX) that is currently
             format the user has selected.  For example, if the user


                 selected by the user.  NOTE: The date input will always
             has selected the DD/MM/YY format, Input will expect the


                 return the date in the MM/DD/YY format, regardless of what
             user to enter the date in that format, but will then


                 format the user has selected.  For example, if the user
             convert it to MM/DD/YY when it returns the date back to


                 has selected the DD/MM/YY format, Input will expect the
             the MPE program.


                 user to enter the date in that format, but will then
         6 : Password input.  Allows all characters, but will convert


                 convert it to MM/DD/YY when it returns the date back to
             any lower case letters into upper case.  The character


                 the MPE program.
             that is typed is NOT echoed to the screen.  Instead, it


             6 : Password input.  Allows all characters, but will convert
             is replaced by the * character so that what they have


                 any lower case letters into upper case.  The character
             entered will not be shown on the screen.


                 that is typed is NOT echoed to the screen.  Instead, it
          7: Lowercase Allows characters but will be lowercase.


                 is replaced by the * character so that what they have
    8: User Defined Input (from system config)


                 entered will not be shown on the screen.
          9: Standard Input with no CR


              7: Lowercase Allows characters but will be lowercase.
         10: Number Input numbers only and +-


           8: User Defined Input (from system config)
    NOTE: If any of the above input values are increased by 10, Input


              9: Standard Input with no CR
    will create an input field using the foreground/background color


             10: Number Input numbers only and +-
    that has been defined for that language.  For example, input type


        NOTE: If any of the above input values are increased by 10, Input
    11 will function the same as input type 1, but will fill an input


        will create an input field using the foreground/background color
    field to the maximum field length.


        that has been defined for that language.  For example, input type
    The Default parameter can be used to force a default text into


        11 will function the same as input type 1, but will fill an input
    the input field.  If you do not wish to have any default text in


        field to the maximum field length.
    the buffer, supply a blank string parameter (ie <nowiki>''</nowiki>).


        The Default parameter can be used to force a default text into
    EXAMPLE:


        the input field.  If you do not wish to have any default text in
    Var Str : String


        the buffer, supply a blank string parameter (ie <nowiki>''</nowiki>).
    Write ('Enter something: ')


        EXAMPLE:
    Str := Input (30, 30, 1, <nowiki>''</nowiki>)


        Var Str : String
    The above example will print the text "Enter something: " to the


        Write ('Enter something: ')
    screen and the allow input of up to 30 characters in length, using


        Str := Input (30, 30, 1, <nowiki>''</nowiki>)
    input type 1 (allows all characters).  No default text has been


        The above example will print the text "Enter something: " to the
    supplied so the input field will be empty by default.


        screen and the allow input of up to 30 characters in length, using
    Var Str : String


        input type 1 (allows all characters).  No default text has been
    Write ('Enter something: ')


        supplied so the input field will be empty by default.
    Str := Input (30, 30, 11, 'Default')


        Var Str : String
    The above example will function just like the first example, except


        Write ('Enter something: ')
    it will create an input field background and stuff the text of


        Str := Input (30, 30, 11, 'Default')
    "Default" into the input field.


        The above example will function just like the first example, except
Function INPUTNY (Text: String) : Boolean


        it will create an input field background and stuff the text of
    This function prompts the user with a Yes/No question, defaulting


        "Default" into the input field.
    to No. TRUE will be returned if the user answered Yes, or FALSE if


   Function INPUTNY (Text: String) : Boolean
    the user answered No.  The passed Text variable is the text that is


        This function prompts the user with a Yes/No question, defaulting
    displayed to the user asking the question.


        to No. TRUE will be returned if the user answered Yes, or FALSE if
    Example:


        the user answered No.  The passed Text variable is the text that is
    If Not InputNY('Do you want to run this program? ') Then


        displayed to the user asking the question.
         Halt


        Example:
    The above example will prompt the user with the Yes/No question


        If Not InputNY('Do you want to run this program? ') Then
    passed as <Text>.  This question will default to No.  If the user


             Halt
    answers No, the program will halt from being executed.


        The above example will prompt the user with the Yes/No question
Function INPUTYN (Text: String) : Boolean


        passed as <Text>.  This question will default to No.  If the user
    This function prompts the user with a Yes/No question, defaulting


        answers No, the program will halt from being executed.
    to Yes.  TRUE will be returned if the user answered Yes, or FALSE


   Function INPUTYN (Text: String) : Boolean
    if the user answered No.  The passed Text variable is the text


        This function prompts the user with a Yes/No question, defaulting
    that is displayed to the user asking the question.


        to Yes.  TRUE will be returned if the user answered Yes, or FALSE
    Example:


        if the user answered No.  The passed Text variable is the text
    If Not InputYN('Do you want to run this program? ') Then


        that is displayed to the user asking the question.
         Halt


        Example:
    The above example will prompt the user with a Yes/No question,


        If Not InputYN('Do you want to run this program? ') Then
    asking "Do you want to run this program?".  If the user responds


             Halt
    No, the program will not run, using the Halt command.


        The above example will prompt the user with a Yes/No question,
Function ISARROW : Boolean


        asking "Do you want to run this program?"If the user responds
    This function is used along with the READKEY functionAfter


        No, the program will not run, using the Halt command.
    READKEY is called, this function can be checked to process various


   Function ISARROW : Boolean
    extended keys, such as arrow keys.  When ISARROW is true, READKEY


        This function is used along with the READKEY function.  After
    will return the following:


        READKEY is called, this function can be checked to process various
    ASCII #     Char     Key Pressed


        extended keys, such as arrow keys.  When ISARROW is true, READKEY
    -------     ----     -----------


        will return the following:
    71          G        Home


        ASCII #     Char     Key Pressed
    72          H        Up Arrow


        -------     ----     -----------
    73          I        Page Up


        71          G        Home
    75          K        Left Arrow


        72          H        Up Arrow
    77          M        Right Arrow


        73          I        Page Up
    79          O        End


        75          K        Left Arrow
    80          P        Down Arrow


        77          M        Right Arrow
    81          Q        Page Down


        79          O        End
    83          S        Delete


        80          P        Down Arrow
    The character returned by READKEY can be checked by either the


        81          Q        Page Down
    ASCII # or the actual character.  Below is an example:


        83          S        Delete
    Example:


        The character returned by READKEY can be checked by either the
    Var Ch : Char


        ASCII # or the actual character.  Below is an example:
    Ch := ReadKey                 # Input one key


        Example:
    If IsArrow Then               # Is key returned an arrow key?


        Var Ch : Char
      If Ch = 'H' Then


        Ch := ReadKey                 # Input one key
        WriteLn ('Up arrow')


        If IsArrow Then               # Is key returned an arrow key?
      Else If Ch = Chr(80) Then


          If Ch = 'H' Then
        WriteLn ('Down arrow')


            WriteLn ('Up arrow')
    Else                          # No arrow key.  A normal character


          Else If Ch = Chr(80) Then
      WriteLn ('You entered character: ', Ch)


            WriteLn ('Down arrow')
    The above example reads a key with READKEY and then uses the


        Else                          # No arrow key.  A normal character
    ISARROW function to process the Up Arrow and Down Arrow keys.


          WriteLn ('You entered character: ', Ch)
Function ISUSER (String) : Boolean


        The above example reads a key with READKEY and then uses the
    This function takes a string value which can contain either a user


        ISARROW function to process the Up Arrow and Down Arrow keys.
    realname, handle, or user perm index number.  If the user exists,


   Function ISUSER (String) : Boolean
    it will return a TRUE result or FALSE if the user does not exist.


        This function takes a string value which can contain either a user
Function KEYPRESSED : Boolean


        realname, handle, or user perm index number.  If the user exists,
    This function returns TRUE if a key has been pressed either


        it will return a TRUE result or FALSE if the user does not exist.
    remotely or locally.  Keep in mind two things about this


   Function KEYPRESSED : Boolean
    function:


        This function returns TRUE if a key has been pressed either
         (1) It doesn't check for inactivity timeout.  If you are


        remotely or locally.  Keep in mind two things about this
             using this function to wait for a key to be pressed then


        function:
             you may want to use the TIMER function and check for


             (1) It doesn't check for inactivity timeout.  If you are
             inactivity.


                 using this function to wait for a key to be pressed then
         (2) This function only returns whether a key was PRESSED.


                 you may want to use the TIMER function and check for
             It does not actually read the key out of the buffer.


                 inactivity.
             See the READKEY function for reading keys from the


             (2) This function only returns whether a key was PRESSED.
             buffer.


                 It does not actually read the key out of the buffer.
    Example:


                 See the READKEY function for reading keys from the
    Repeat


                 buffer.
    Until KeyPressed


        Example:
    WriteLn ('You pressed a key!')


        Repeat
    The above example will wait for a key to be pressed and then


        Until KeyPressed
    write to the screen "You pressed a key!".


        WriteLn ('You pressed a key!')
  Function MCI2STR (String) : String


        The above example will wait for a key to be pressed and then
    This function will take the value of the supplied 2-character MCI


        write to the screen "You pressed a key!".
    code (without pipe) and returns the string value of that code.


     Function MCI2STR (String) : String
    Ex:


        This function will take the value of the supplied 2-character MCI
    Var BBSName : String


        code (without pipe) and returns the string value of that code.
    


        Ex:
    BBSName:=MCI2Str('BN')


        Var BBSName : String
    WriteLn('The name of this BBS is "'+BBSName+'"')


        
  Function MCILENGTH (String) : Integer


        BBSName:=MCI2Str('BN')
    This function works just like LENGTH except it tries to ignore MCI


        WriteLn('The name of this BBS is "'+BBSName+'"')
    codes.  It doesn't check for actual validity of MCI codes.


     Function MCILENGTH (String) : Integer
    Var B : Byte;


        This function works just like LENGTH except it tries to ignore MCI
    B := MCILength('|15Hello|UH');


        codes.  It doesn't check for actual validity of MCI codes.
    WriteLn ('Length should be 5: ' + Int2Str(B));


        Var B : Byte;
  Function MOREPROMPT : Char


        B := MCILength('|15Hello|UH');
    This function displays the system more prompt and returns a Char


        WriteLn ('Length should be 5: ' + Int2Str(B));
    value of either Y N or C depending on what the user selected.


    Var C : Char


     Function MOREPROMPT : Char
    C:=MorePrompt


        This function displays the system more prompt and returns a Char
Procedure MOVEX (Pos : Byte)


        value of either Y N or C depending on what the user selected.
        This procedure is used to move the cursor to the passed X coordinate


        Var C : Char
        on the screen.  It only works if the user has ANSI graphics enabled.


        C:=MorePrompt
        Example:


       Procedure MOVEX (Pos : Byte)
        MoveX (20)


                This procedure is used to move the cursor to the passed X coordinate
        WriteLn ('This text starts on the 20th space')


                on the screen.  It only works if the user has ANSI graphics enabled.
Procedure MOVEY (Pos : Byte)


                Example:
        This procedure is used to move the cursor to the passed Y coordinate


                MoveX (20)
        on the screen.  It only works if the user has ANSI graphics enabled.


                WriteLn ('This text starts on the 20th space')
        Example:


       Procedure MOVEY (Pos : Byte)
        MoveY (10)


                This procedure is used to move the cursor to the passed Y coordinate
        WriteLn ('This is on the 10th line of the screen')


                on the screen.  It only works if the user has ANSI graphics enabled.
Function PARAMCOUNT : Byte


                Example:
    This function is used to determine the number of command line


                MoveY (10)
    options which have been passed to the MPE program.  For more


                WriteLn ('This is on the 10th line of the screen')
    information, see the PARAMSTR function.


       Function PARAMCOUNT : Byte
    Example:


        This function is used to determine the number of command line
    If ParamCount < 2 Then Begin


        options which have been passed to the MPE program.  For more
         WriteLn ('Invalid command line.')


        information, see the PARAMSTR function.
         Halt


        Example:
    End


        If ParamCount < 2 Then Begin
    The above example will check to see if less than 2 command line


             WriteLn ('Invalid command line.')
    options have been passed to the MPE program.  If there are less


             Halt
    than two, the program will terminal with a "invalid command line"


        End
    message.


        The above example will check to see if less than 2 command line
Function PARAMSTR (Number : Byte) : String


        options have been passed to the MPE program.  If there are less
    This function returns the command line option specified by the


        than two, the program will terminal with a "invalid command line"
    NUMBER parameter.  A command line is the optional data which


        message.
    is passed on the "Data" field of a menu command.  For example,


   Function PARAMSTR (Number : Byte) : String
    when defining a menu command which executes an MPE program in


        This function returns the command line option specified by the
    the menu editor, the text after the program name becomes command


        NUMBER parameter.  A command line is the optional data which
    line options.


        is passed on the "Data" field of a menu command.  For example,
    Menu Command: GX


        when defining a menu command which executes an MPE program in
    Data        : BULLETIN p1 p2 p3 p4


        the menu editor, the text after the program name becomes command
    If the above was defined in the menu editor, the following would


        line options.
    be true:


        Menu Command: GX
    ParamCount  would return 4


        Data        : BULLETIN p1 p2 p3 p4
    ParanStr(0) would return "BULLETIN"


        If the above was defined in the menu editor, the following would
    ParamStr(1) would return "p1"


        be true:
    ParamStr(2) would return "p2"


        ParamCount  would return 4
    ParamStr(3) would return "p3"


        ParanStr(0) would return "BULLETIN"
    ParamStr(4) would return "p4"


        ParamStr(1) would return "p1"
    Note that ParamStr(0) will ALWAYS return the file name of the


        ParamStr(2) would return "p2"
    MPE program being executed.  Even when there are no other


        ParamStr(3) would return "p3"
    parameters defined.


        ParamStr(4) would return "p4"
Procedure PAUSE


        Note that ParamStr(0) will ALWAYS return the file name of the
    Envokes the Mystic pause prompt as defined in the current


        MPE program being executed.  Even when there are no other
    language file.


        parameters defined.
Function PAUSEPOS : Byte


   Procedure PAUSE
 


        Envokes the Mystic pause prompt as defined in the current
    This function gives access to Mystic's internal line


        language file.
    counter used for screen pauses.


   Function PAUSEPOS : Byte
Function RANDOM (Max: Word) : Word


     
    This function will return a random number within the range


        This function gives access to Mystic's internal line
    specified.


        counter used for screen pauses.
    Example:


   Function RANDOM (Max: Word) : Word
    Var A : Byte


        This function will return a random number within the range
    A := Random(255)


        specified.
    WriteLn (A)


        Example:
    The above example will generate a random number within the range


        Var A : Byte
    of 0 to 255 in the variable A and then print it to the screen.


        A := Random(255)
Function READKEY : Char


        WriteLn (A)
    This function will read a key from the buffer and return it as


        The above example will generate a random number within the range
    a char variable.  If there are no keys in the buffer, readkey will


        of 0 to 255 in the variable A and then print it to the screen.
    wait for a key to be pressed.


   Function READKEY : Char
    Example:


        This function will read a key from the buffer and return it as
    Var Ch : Char


        a char variable.  If there are no keys in the buffer, readkey will
    Repeat Until KeyPressed


        wait for a key to be pressed.
    Ch := ReadKey


        Example:
    WriteLn ('You entered: ', Ch)


        Var Ch : Char
    The above example will wait for a key to be pressed by using the


        Repeat Until KeyPressed
    KEYPRESSED function.  Afterwards, the key will be read into the


        Ch := ReadKey
    CH variable using readkey, and then print it to the screen.


        WriteLn ('You entered: ', Ch)
Procedure SETPROMPTINFO (N : Integer; S : String)


        The above example will wait for a key to be pressed by using the
   This allows you to set Mystic's internal "changing" PromptInfo MCI


        KEYPRESSED functionAfterwards, the key will be read into the
   codes (the |&X codes)For example:


        CH variable using readkey, and then print it to the screen.
   SetPromptInfo(1, 'Hello!');


   Procedure SETPROMPTINFO (N : Integer; S : String)
   WriteLn ('This MCI code would like to say: |&1');


       This allows you to set Mystic's internal "changing" PromptInfo MCI
   As a side note, there is NOT a GetPromptInfo because you can simply use


       codes (the |&X codes).  For example:
   MCI2STR:


       SetPromptInfo(1, 'Hello!');
   WriteLn('This MCI code would like to say: ' + Mci2Str('&1'));


       WriteLn ('This MCI code would like to say: |&1');
Procedure STUFFKEY (S : String)


       As a side note, there is NOT a GetPromptInfo because you can simply use
    This function will stuff a string of text into the keyboard


       MCI2STR:
    buffer.  This can be used to force your program into thinking


       WriteLn('This MCI code would like to say: ' + Mci2Str('&1'));
    the user had actually typed <nowiki><S>.</nowiki>


   Procedure STUFFKEY (S : String)
    Example:


        This function will stuff a string of text into the keyboard
    Var Ch : Char


        buffer.  This can be used to force your program into thinking
    StuffKey ('A')


        the user had actually typed <nowiki><S>.</nowiki>
    Ch := ReadKey


        Example:
    WriteLn ('You entered: ', Ch)


        Var Ch : Char
    The above example will stuff the character "A" into the input


        StuffKey ('A')
    buffer, where it will be read into Ch using the ReadKey function.


        Ch := ReadKey
    It is possible to stuff entire strings of text into the buffer


        WriteLn ('You entered: ', Ch)
    too.


        The above example will stuff the character "A" into the input
    Example:


        buffer, where it will be read into Ch using the ReadKey function.
    Var Str : String


        It is possible to stuff entire strings of text into the buffer
    StuffKey 'Hello World'


        too.
    Str := Input (20, 20, 1, <nowiki>''</nowiki>)


        Example:
    The above example will stuff "Hello World" into the input buffer.


        Var Str : String
    This will cause the input function to think the user has actually


        StuffKey 'Hello World'
    typed in "Hello World".  In this case, the above is the same as


        Str := Input (20, 20, 1, <nowiki>''</nowiki>)
    supplying "Hello World" in the <DEFAULT> field of the Input


        The above example will stuff "Hello World" into the input buffer.
    function.


        This will cause the input function to think the user has actually
Function TIMER : LongInt


        typed in "Hello World".  In this case, the above is the same as
    This function will return the current number of seconds which have


        supplying "Hello World" in the <DEFAULT> field of the Input
    passed since midnight.  This function can be used to time how long


        function.
    a user is doing something.


   Function TIMER : LongInt
    Example:


        This function will return the current number of seconds which have
    Var StartTime : LongInt


        passed since midnight.  This function can be used to time how long
    Var EndTime   : LongInt


        a user is doing something.
    Var Total     : LongInt


        Example:
    Var Str       : String


        Var StartTime : LongInt
    StartTime := Timer


        Var EndTime   : LongInt
    Write ('Enter something: ')


        Var Total     : LongInt
    Str := Input (40, 11, 'Nothing')


        Var Str       : String
    EndTime := Timer


        StartTime := Timer
    Total := EndTime - StartTime


        Write ('Enter something: ')
    WriteLn ('You took ', Total, ' seconds to type something!')


        Str := Input (40, 11, 'Nothing')
    The above example will prompt the user to type something and time


        EndTime := Timer
    how long in seconds they took.  WriteLn will then display the


        Total := EndTime - StartTime
    number of seconds the user took to the screen.


        WriteLn ('You took ', Total, ' seconds to type something!')
Function TIMERMIN : LongInt


        The above example will prompt the user to type something and time
    This function works just like TIMER except returns minues


        how long in seconds they took.  WriteLn will then display the
    instead of seconds.


        number of seconds the user took to the screen.
Function WHEREX : Byte


   Function TIMERMIN : LongInt
    This function returns the current X coordinate of the cursor.


        This function works just like TIMER except returns minues
    Example:


        instead of seconds.
    Var X : Byte


   Function WHEREX : Byte
    Var Y : Byte


        This function returns the current X coordinate of the cursor.
    X := WhereX


        Example:
    Y := WhereY


        Var X : Byte
    WriteLn ('      World')


        Var Y : Byte
    GotoXY  (X, Y)


        X := WhereX
    WriteLn ('Hello')


        Y := WhereY
    The above example will save the current X and Y cursor positions


        WriteLn ('      World')
    and then write the text "World" to the screen.  After which, it


        GotoXY  (X, Y)
    will return to the saved X and Y position and write the text


        WriteLn ('Hello')
    "Hello" to the screen.  The end result will be the text of


        The above example will save the current X and Y cursor positions
    "Hello World" written to the screen.  Note: GotoXY can only be


        and then write the text "World" to the screen.  After which, it
    used if the user has ANSI graphics mode.


        will return to the saved X and Y position and write the text
Function WHEREY : Byte


        "Hello" to the screen.  The end result will be the text of
    This function returns the current Y coordinate of the cursor.


        "Hello World" written to the screen.  Note: GotoXY can only be
    For more information on this function, please see the definition


        used if the user has ANSI graphics mode.
    of the WHEREX function.


   Function WHEREY : Byte
Procedure WRITE (Text)


        This function returns the current Y coordinate of the cursor.
    This procedure is used to write text to the screen without


        For more information on this function, please see the definition
    going to the next line (ie, without sending a carriage return).


        of the WHEREX function.
    All text to be printed to the screen should be enclosed inside of


   Procedure WRITE (Text)
    ' characters.  If you wish to print the value of a variable to


        This procedure is used to write text to the screen without
    the screen, just include the variable name without the '


        going to the next line (ie, without sending a carriage return).
    characters.  If you wish to combine multiple text and variables,


        All text to be printed to the screen should be enclosed inside of
    they must be separated by commas.


        ' characters.  If you wish to print the value of a variable to
    Examples:


        the screen, just include the variable name without the '
    Write ('Hello ')


        characters.  If you wish to combine multiple text and variables,
    Write ('World')


        they must be separated by commas.
    This example will write the text "Hello World" to the screen.


        Examples:
    Write ('Hello World')


        Write ('Hello ')
    This example does the exact same thing as the function above, but


        Write ('World')
    makes a little more sense.


        This example will write the text "Hello World" to the screen.
    Var Str : String


        Write ('Hello World')
    Str := 'Hello World'


        This example does the exact same thing as the function above, but
    Write (Str)


        makes a little more sense.
    This example will write the value held in the variable Str to the


        Var Str : String
    screen.  The resulting output will be "Hello World"


        Str := 'Hello World'
    Var Str : String


        Write (Str)
    Str := 'Hello '


        This example will write the value held in the variable Str to the
    Write (Str, 'World')


        screen.  The resulting output will be "Hello World"
    This example will write the value of the variable Str to the


        Var Str : String
    screen, followed by the text "World".  The resulting output will


        Str := 'Hello '
    be "Hello World".  An unlimited number of variables and text can


        Write (Str, 'World')
    be outputted with the Write statement, but they must all be


        This example will write the value of the variable Str to the
    separated by a comma, as shown above.


        screen, followed by the text "World".  The resulting output will
    If a ' character needs to be printed to the screen, it can be done


        be "Hello World"An unlimited number of variables and text can
    by doubling the ' characterFor example:


        be outputted with the Write statement, but they must all be
    Write (<nowiki>'This is how it''s done.'</nowiki>)


        separated by a comma, as shown above.
    The resulting screen output will be "This is how it's done", with


        If a ' character needs to be printed to the screen, it can be done
    only one ' character.


        by doubling the ' characterFor example:
    All MCI display codes can be used within the Write statementIf


        Write (<nowiki>'This is how it''s done.'</nowiki>)
    you wish to change the display colors, use the MCI color system to


        The resulting screen output will be "This is how it's done", with
    do so.  For example:


        only one ' character.
    Write ('~14Hello World')


        All MCI display codes can be used within the Write statement.  If
    This example will write the text Hello World in yellow to the


        you wish to change the display colors, use the MCI color system to
    screen.  All MCI display codes are available to the write


        do so.  For example:
    statement.


        Write ('~14Hello World')
Procedure WRITELN (Text)


        This example will write the text Hello World in yellow to the
    This procedure outputs text to the screen.  It functioning is


        screen.  All MCI display codes are available to the write
    identical to the WRITE statement except that it goes to the next


        statement.
    line after the text is printed (ie, it sends a carriage return).


   Procedure WRITELN (Text)
    For example:


        This procedure outputs text to the screen.  It functioning is
    WriteLn ('Hello')


        identical to the WRITE statement except that it goes to the next
    WriteLn ('World')


        line after the text is printed (ie, it sends a carriage return).
    The above example will write the text "Hello" on one line, and


        For example:
    then the text of "World" on the next line.


        WriteLn ('Hello')
Procedure WRITEPIPE (Text)


        WriteLn ('World')
    This function works just like WRITE but only parses pipe color


        The above example will write the text "Hello" on one line, and
    codes instead of all MCI codes.


        then the text of "World" on the next line.
Procedure WRITEPIPELN (Text)


   Procedure WRITEPIPE (Text)
    This procedure works just like WRITEPIPE but with a CRLF at the end.


   
Procedure WRITERAW (Text)


        This function works just like WRITE but only parses pipe color
    This procedure works just like WRITE except it does not parse


        codes instead of all MCI codes.
    any pipe color codes OR MCI codes.


   Procedure WRITEPIPELN (Text)
Procedure WRITERAWLN (Text)


   
    This procedure is the same as WRITERAW, but with a CRLF at the end.


        This procedure works just like WRITEPIPE but with a CRLF at the end.
Procedure WRITEXY (X,Y,Z: Byte; Str : String)


   Procedure WRITERAW (Text)
    This procedure writes a string of text at the defined X/Y location with a


        This procedure works just like WRITE except it does not parse
    specific text color attribute 'Z'.  This of course requires the user has


        any pipe color codes OR MCI codes.
    ANSI to function properly.  This function will NOT parse MCI pipe codes.


   Procedure WRITERAWLN (Text)
    Example:


        This procedure is the same as WRITERAW, but with a CRLF at the end.
    WriteXY (1, 10, 8, 'Prints at X:1 Y:10 with dark grey text');


   
Procedure WRITEXYPIPE (X,Y,Z: Byte; Len: Integer; Str : String)


   Procedure WRITEXY (X,Y,Z: Byte; Str : String)
    This procedure writes a string of text at the defined X/Y location with a


        This procedure writes a string of text at the defined X/Y location with a
    specific text color attribute 'Z'.  This of course requires the user has


        specific text color attribute 'Z'.  This of course requires the user has
    ANSI to function properly.  This function will NOT parse MCI pipe codes.


        ANSI to function properly.  This function will NOT parse MCI pipe codes.
    Example:


        Example:
    WriteXYPipe (1, 10, 8, 50, 'This pads to 50 chars at location 1,10');


        WriteXY (1, 10, 8, 'Prints at X:1 Y:10 with dark grey text');
<nowiki>-----------------------------------------------------------------------</nowiki>


   Procedure WRITEXYPIPE (X,Y,Z: Byte; Len: Integer; Str : String)
String Handling Functions and Procedures


        This procedure writes a string of text at the defined X/Y location with a
<nowiki>-----------------------------------------------------------------------</nowiki>


        specific text color attribute 'Z'.  This of course requires the user has
Function ADDSLASH(S: String) : String


        ANSI to function properly.  This function will NOT parse MCI pipe codes.
   takes a directory and appends the appropriate ending backslash or


        Example:
   forward slash depending on operating system.  If the slash is already


        WriteXYPipe (1, 10, 8, 50, 'This pads to 50 chars at location 1,10');
   there, it does nothing.


   -----------------------------------------------------------------------
Function CHR (B: Byte) : Char


   String Handling Functions and Procedures
    This function will take a numerical byte value and return it's


   -----------------------------------------------------------------------
    ASCII character.  The byte value must be between 0 and 255 as


   Function ADDSLASH(S: String) : String
    there are only 255 characters in the ASCII character set.


       takes a directory and appends the appropriate ending backslash or
    Example:


       forward slash depending on operating system.  If the slash is already
    WriteLn ('Hello', Chr(32), 'World')


       there, it does nothing.
    This will output the text "Hello World" to the screen.  The ASCII


   Function CHR (B: Byte) : Char
    number for the space character is 32 and by passing a 32 to CHR,


        This function will take a numerical byte value and return it's
    a space is returned.


        ASCII character.  The byte value must be between 0 and 255 as
Function COPY (S: String, Index: Byte, Count: Byte) : String;


        there are only 255 characters in the ASCII character set.
    This function will copy a defined part of a string and return


        Example:
    the copied portion as a string.


        WriteLn ('Hello', Chr(32), 'World')
    Example:


        This will output the text "Hello World" to the screen.  The ASCII
    Var Str : String


        number for the space character is 32 and by passing a 32 to CHR,
    Str := 'Hello World'


        a space is returned.
    WriteLn (Copy(Str, 1, 5))


   Function COPY (S: String, Index: Byte, Count: Byte) : String;
    This will output "Hello" to the screen.  The copy function takes


        This function will copy a defined part of a string and return
    the given Str and copies Count number of character from the Index.


        the copied portion as a string.
    So the above copies 5 characters starting at the 1st character in


        Example:
    Str and WriteLn outputs it to the screen.


        Var Str : String
Procedure DELETE (S: String, Index: Byte, Count: Byte)


        Str := 'Hello World'
    This procedure will delete a defined portion of a string


        WriteLn (Copy(Str, 1, 5))
    variable.


        This will output "Hello" to the screen.  The copy function takes
    Example:


        the given Str and copies Count number of character from the Index.
    Var Str : String


        So the above copies 5 characters starting at the 1st character in
    Str := 'Hello World'


        Str and WriteLn outputs it to the screen.
    Delete (Str, 6, 6);


   Procedure DELETE (S: String, Index: Byte, Count: Byte)
    WriteLn (Str)


        This procedure will delete a defined portion of a string
    This example will delete 6 characters from the string Str starting


        variable.
    at the 6th character.  The resulting output from WriteLn will be


        Example:
    "Hello"


        Var Str : String
Function FillChar (V: Variable; S: LongInt; C Char ): String


        Str := 'Hello World'
    Fills variable V with Char C for S size.


        Delete (Str, 6, 6);
    type


        WriteLn (Str)
      myuserrecord = record


        This example will delete 6 characters from the string Str starting
<nowiki>      username  : string[30];</nowiki>


        at the 6th character.  The resulting output from WriteLn will be
<nowiki>      somevalue : array[1..5] of byte;</nowiki>


        "Hello"
    end;


    Function FillChar (V: Variable; S: LongInt; C Char ): String
    var


        Fills variable V with Char C for S size.
      u : myuserrecord;


        type
    begin


          myuserrecord = record
      fillchar(u, sizeof(u), #0);


<nowiki>          username  : string[30];</nowiki>
    end.


<nowiki>          somevalue : array[1..5] of byte;</nowiki>
Procedure INSERT (Source: String, Target: String, Index: Byte)


        end;
    This procedure will insert text into a string at a specified


        var
    location.


          u : myuserrecord;
    Example:


        begin
    Var Str : String


          fillchar(u, sizeof(u), #0);
    Str := 'Mystic v1.00'


        end.
    Insert ('BBS ', Str, 8)


   Procedure INSERT (Source: String, Target: String, Index: Byte)
    WriteLn (Str)


        This procedure will insert text into a string at a specified
    The above example will insert the text "BBS" into the Str variable


        location.
    starting at the 8th character in the string.  The result WriteLn


        Example:
    output would be "Mystic BBS v1.00"


        Var Str : String
Function INT2STR (L: LongInt) : String


        Str := 'Mystic v1.00'
    This function converts a numerical type variable to a string


        Insert ('BBS ', Str, 8)
    type variable.


        WriteLn (Str)
    Example:


        The above example will insert the text "BBS" into the Str variable
    Var A : Byte


        starting at the 8th character in the string.  The result WriteLn
    Var S : String


        output would be "Mystic BBS v1.00"
    A := 255


   Function INT2STR (L: LongInt) : String
    S := Int2Str(A)


        This function converts a numerical type variable to a string
    WriteLn (S)


        type variable.
    The above example sets the numerical variable to the value of


        Example:
    255, which is then converted to a string variable using Int2Str.


        Var A : Byte
    The resulting value of S will be '255' as WriteLn will output to


        Var S : String
    the screen.


        A := 255
Function LENGTH (S: String) : Byte


        S := Int2Str(A)
    This function returns the length in characters of the passed


        WriteLn (S)
    string variable.


        The above example sets the numerical variable to the value of
    Example:


        255, which is then converted to a string variable using Int2Str.
    WriteLn (Length('Hello World'))


        The resulting value of S will be '255' as WriteLn will output to
    The above example would output "11" to the screen, which is the


        the screen.
    number of characters in the text passed to Length.


   Function LENGTH (S: String) : Byte
Function LOWER (S: String) : String


        This function returns the length in characters of the passed
    This function converts a passed string variable to all lower


        string variable.
    case letters.


        Example:
    Example:


        WriteLn (Length('Hello World'))
    WriteLn (Lower('HELLO'))


        The above example would output "11" to the screen, which is the
    The above statement would output the text "hello" to the screen.


        number of characters in the text passed to Length.
    The original text of HELLO is converted to all lower case letters


   Function LOWER (S: String) : String
    and than displayed by WriteLn.


        This function converts a passed string variable to all lower
Function ONEKEY (Keys : String; Echo : Boolean) : Char


        case letters.
    This function accepts a string of uppercase letters, and wait for


        Example:
    input from the user.  If the keystroke is among the characters in


        WriteLn (Lower('HELLO'))
    Keys, it will return that character.  If the keystroke is not among


        The above statement would output the text "hello" to the screen.
    the Keys string, it will do nothing.  If Echo is set to TRUE, it


        The original text of HELLO is converted to all lower case letters
    will also echo the Key to the screen.


        and than displayed by WriteLn.
    Var Ch   : Char


   Function ONEKEY (Keys : String; Echo : Boolean) : Char
    Var Keys : String = 'ABCDQ'


        This function accepts a string of uppercase letters, and wait for
    Ch := OneKey(Keys,True)


        input from the user.  If the keystroke is among the characters in
    WriteLn('You selected '+Ch+'.')


        Keys, it will return that character.  If the keystroke is not among
Function ONEKEYRANGE (String, Int, Int ) : Char


        the Keys string, it will do nothing.  If Echo is set to TRUE, it
    This function works similar to OneKey, except that it will also allow


        will also echo the Key to the screen.
    for a number input within a certain range.  The number value is


        Var Ch   : Char
    stored in a variable called RangeValue and the function returns a #0


        Var Keys : String = 'ABCDQ'
    if a number was entered.  For example:


        Ch := OneKey(Keys,True)
    Var


        WriteLn('You selected '+Ch+'.')
      Ch : Char;


   Function ONEKEYRANGE (String, Int, Int ) : Char
    Begin


   
      Write ('Enter letters A-G or a number between 1-50: ');


        This function works similar to OneKey, except that it will also allow
      Ch := OneKeyRange('ABCDEFG', 1, 50);


        for a number input within a certain range.  The number value is
      If Ch = #0 Then


        stored in a variable called RangeValue and the function returns a #0
        WriteLn ('You entered a number: ' + Int2Str(RangeValue))


        if a number was entered.  For example:
      Else


        Var
        WriteLn ('You entered character: ' + Ch);


          Ch : Char;
    End.


        Begin
Function ORD (C: Char) : Byte


          Write ('Enter letters A-G or a number between 1-50: ');
    This function returns the ASCII code of the passed Char variable.


          Ch := OneKeyRange('ABCDEFG', 1, 50);
    This function works the exact opposite of the CHR function.


          If Ch = #0 Then
    Example:


            WriteLn ('You entered a number: ' + Int2Str(RangeValue))
    WriteLn (Ord(' '))


          Else
    The above example would output the text "32" to the screen because


            WriteLn ('You entered character: ' + Ch);
    32 is the ASCII character code for space.


        End.
Function PADCT (S: String, N: Byte, C: Char) : String


   Function ORD (C: Char) : Byte
    This function pads a string to the center with the specified


        This function returns the ASCII code of the passed Char variable.
    character.


        This function works the exact opposite of the CHR function.
    Example:


        Example:
    Var Str : String


        WriteLn (Ord(' '))
    Str := PadCT('Hello World', 80, ' ')


        The above example would output the text "32" to the screen because
    WriteLn (Str)


        32 is the ASCII character code for space.
    The above example would display the text "Hello World" centered on


   Function PADCT (S: String, N: Byte, C: Char) : String
    the screen.  The PadCT function returns the text "Hello World"


        This function pads a string to the center with the specified
    centered in 80 spaces with the character of " " used to fill the


        character.
    blank spaces.


        Example:
Function PADLT (S: String, N: Byte, C: Char) : String


        Var Str : String
    This function returns a text string padded with spaces to the


        Str := PadCT('Hello World', 80, ' ')
    left side.


        WriteLn (Str)
    Example:


        The above example would display the text "Hello World" centered on
    Var Str : String


        the screen.  The PadCT function returns the text "Hello World"
    Str := PadLT('Hello World', 79, ' ')


        centered in 80 spaces with the character of " " used to fill the
    The above example would return a string which is 79 characters in


        blank spaces.
    length with the text "Hello World" as the leftmost part of the


   Function PADLT (S: String, N: Byte, C: Char) : String
    string.  The passed character is the character that is used to


        This function returns a text string padded with spaces to the
    fill the blank spaces.


        left side.
Function PADRT (S: String, N: Byte, C: Char) : String


        Example:
    This function returns a text string padded with spaces to the


        Var Str : String
    right side.


        Str := PadLT('Hello World', 79, ' ')
    Example:


        The above example would return a string which is 79 characters in
    Var Str : String


        length with the text "Hello World" as the leftmost part of the
    Str := PadRT('Hello World', 79, ' ')


        string.  The passed character is the character that is used to
    The above example would return a string which is 79 characters in


        fill the blank spaces.
    length with the text "Hello World" being the rightmost part of the


   Function PADRT (S: String, N: Byte, C: Char) : String
    string.  The empty spaces are filled with the passed charcter (in


        This function returns a text string padded with spaces to the
    this case ' ').


        right side.
Function POS (Sub: String, S: String) : Byte


        Example:
    This function returns the starting position of a substring in a


        Var Str : String
    string.


        Str := PadRT('Hello World', 79, ' ')
    Example:


        The above example would return a string which is 79 characters in
    Var A : Byte


        length with the text "Hello World" being the rightmost part of the
    A := POS('World', 'Hello World')


        string.  The empty spaces are filled with the passed charcter (in
    WriteLn (A)


        this case ' ').
    The above example would output "7" to the screen becase POS


   Function POS (Sub: String, S: String) : Byte
    returns the position of the text "World" in the string


        This function returns the starting position of a substring in a
    "Hello World".  If POS does not find a match, a zero will be


        string.
    returned.  IE: A := POS('Blah', 'Hello World') would return a zero


        Example:
    because the text "Blah" was not found in the string "Hello World".


        Var A : Byte
Function REPLACE(Str1, Str2, Str3 : String) : String


        A := POS('World', 'Hello World')
    This function replaces all occurances of a supplied text and


        WriteLn (A)
    returns a string.  Ex:


        The above example would output "7" to the screen becase POS
    Var Str : String = 'Hello Hello Hello';


        returns the position of the text "World" in the string
    Str := Replace(Str, 'Hello', 'World');  // Str is now World World World


        "Hello World".  If POS does not find a match, a zero will be
Function STRCOMMA(LI : LongInt) : String


        returned.  IE: A := POS('Blah', 'Hello World') would return a zero
    This function  accepts a longint and returns it as a string, with


        because the text "Blah" was not found in the string "Hello World".
    commas added where applicable:


   Function REPLACE(Str1, Str2, Str3 : String) : String
    Ex:


        This function replaces all occurances of a supplied text and
    WriteLn (strComma(1000000));  // will print 1,000,000


        returns a string.  Ex:
Function STR2INT (S: String) : LongInt


        Var Str : String = 'Hello Hello Hello';
    This function converts a passed string variable to a numerical


        Str := Replace(Str, 'Hello', 'World');  // Str is now World World World
    variable.  The passed string variable must contain a valid number.


   Function STRCOMMA(LI : LongInt) : String
    Example:


        This function  accepts a longint and returns it as a string, with
    Var A : Byte


        commas added where applicable:
    Var S : String


        Ex:
    S := '100'


        WriteLn (strComma(1000000));  // will print 1,000,000
    A := Str2Int(S)


   Function STR2INT (S: String) : LongInt
    WriteLn (S)


        This function converts a passed string variable to a numerical
    WriteLn (A)


        variable.  The passed string variable must contain a valid number.
    The above example will output "100" twice the screen.  The


        Example:
    variable S is assigned to '100' and the function Str2Int converts


        Var A : Byte
    the string into a numerical value which is assigned to variable


        Var S : String
    A.


        S := '100'
Function STRIPB (S1, S2 : String) : String


        A := Str2Int(S)
    This function strips both sides of the string if a specific character.


        WriteLn (S)
    Var S : String = '     Hello     ';


        WriteLn (A)
    S := StripB(S, ' ');


        The above example will output "100" twice the screen.  The
Function STRIPL (S1, S2 : String) : String


        variable S is assigned to '100' and the function Str2Int converts
    This function strips the left side of a string of any specified


        the string into a numerical value which is assigned to variable
    leading characters.


        A.
    Var S : String = '    Hello';


   Function STRIPB (S1, S2 : String) : String
    S := StripL(S, ' ');


        This function strips both sides of the string if a specific character.
Function STRIPR (S1, S2 : String) : String


        Var S : String = '     Hello     ';
    This function strips the right side of a string of any specifcied


        S := StripB(S, ' ');
    trailing character:


   Function STRIPL (S1, S2 : String) : String
    Var S : String = 'Hello     ';


        This function strips the left side of a string of any specified
    S := StripR(S, ' ');


        leading characters.
Function STRIPLOW (String) : String


        Var S : String = '    Hello';
    This function strips all chracters from a string that are less than


        S := StripL(S, ' ');
    ascii code #32.


   Function STRIPR (S1, S2 : String) : String
    Var S : String = #12#12#12#12 + 'Hello';


        This function strips the right side of a string of any specifcied
    S := StripLow(S);


        trailing character:
Function STRIPMCI (S : String) : String


        Var S : String = 'Hello     ';
    This function will strip the passed string variable of all MCI


        S := StripR(S, ' ');
    codes and return the "cleaned" version.


   Function STRIPLOW (String) : String
    Example


        This function strips all chracters from a string that are less than
    Var S : String


        ascii code #32.
    S := '|10|H|02ello |10W|02orld|07'


        Var S : String = #12#12#12#12 + 'Hello';
    WriteLn ('Normal   : ', S)


        S := StripLow(S);
    WriteLn ('Stripped : ', StripMCI(S))


   Function STRIPMCI (S : String) : String
    The above example assigns a string with MCI codes in it to the S


        This function will strip the passed string variable of all MCI
    variable.  It then writes the original string and the stripped


        codes and return the "cleaned" version.
    string to the screen, so the difference is shown.


        Example
Function STRIPPIPE (String) : String


        Var S : String
    This function takes a string and strips only pipe color codes


        S := '|10|H|02ello |10W|02orld|07'
    from it.


        WriteLn ('Normal   : ', S)
    S := StripPipe('|15Hello there, |UH');  //returns "Hello There, |UH"


        WriteLn ('Stripped : ', StripMCI(S))
Function STRMCI (String) : String


        The above example assigns a string with MCI codes in it to the S
    This function takes an entire string and attempts to translate any


        variable.  It then writes the original string and the stripped
    MCI codes found in it, returning the entire result.


        string to the screen, so the difference is shown.
    S := StrMci('Hello |UH');


   Function STRIPPIPE (String) : String
Function STRREP (Ch: Char, Num: Byte) : String


        This function takes a string and strips only pipe color codes
    This function returns a string filled with character <CH> to the


        from it.
    length of <NUM>.


        S := StripPipe('|15Hello there, |UH');  //returns "Hello There, |UH"
    Example:


   Function STRMCI (String) : String
    WriteLn (strRep('-', 60 ))


        This function takes an entire string and attempts to translate any
    The above example will use strRep to create a string 60 characters


        MCI codes found in it, returning the entire result.
    long of the character '-', then write it to the screen.  So the


        S := StrMci('Hello |UH');
    outputted text would look like:


   Function STRREP (Ch: Char, Num: Byte) : String
    "------------------------------------------------------------"


        This function returns a string filled with character <CH> to the
Function STRWRAP(Str, Str2 : String; Len: Integer) : Byte


        length of <NUM>.
    This function takes two strings and wraps them after the word closest


        Example:
    to the maximum supplied length.  It optionally returns the actual


        WriteLn (strRep('-', 60 ))
    position where it wrapped.


        The above example will use strRep to create a string 60 characters
    Var Str   : String = 'This will wrap';


        long of the character '-', then write it to the screen.  So the
    Var Str2  : String = <nowiki>''</nowiki>;


        outputted text would look like:
    Var Where : Byte;


        "------------------------------------------------------------"
    Where := strWrap(Str, Str2, 10);


   Function STRWRAP(Str, Str2 : String; Len: Integer) : Byte
    WriteLn ('It wrapped at ' + Int2Str(Where));


        This function takes two strings and wraps them after the word closest
    WriteLn ('First string: ' + Str);


        to the maximum supplied length.  It optionally returns the actual
    WriteLn ('Second string: ' + Str2);


        position where it wrapped.
Function UPPER (S: String) : String


        Var Str   : String = 'This will wrap';
    This function coverts the passed string variable to all upper


        Var Str2  : String = <nowiki>''</nowiki>;
    case letters.


        Var Where : Byte;
    Example:


        Where := strWrap(Str, Str2, 10);
    WriteLn (Upper('hello'))


        WriteLn ('It wrapped at ' + Int2Str(Where));
    The above example would output the text "HELLO" to the screen.


        WriteLn ('First string: ' + Str);
    The UPPER function converts the passed text of "hello" to all


        WriteLn ('Second string: ' + Str2);
    upper cased letters, which is then printed to the screen by


   Function UPPER (S: String) : String
    WriteLn.


        This function coverts the passed string variable to all upper
Function WORDCOUNT (S,C: String) : Integer


        case letters.
    Function WordCount returns the number of words in a string using


        Example:
    the final parameter to define the character that determines what


        WriteLn (Upper('hello'))
    separates words.  Ex:


        The above example would output the text "HELLO" to the screen.
    Str := 'Hello this is a test';


        The UPPER function converts the passed text of "hello" to all
    WriteLn ('Str has ' + Int2Str(WordCount(Str, ' ')) + ' words in it.');


        upper cased letters, which is then printed to the screen by
Function WORDGET(I : Integer, S, C : String) : String


        WriteLn.
    returns the actual word at a specific word count.


   Function WORDCOUNT (S,C: String) : Integer
    S is the inputted string value.


        Function WordCount returns the number of words in a string using
    I is the numerical value of the position where the word can be found.


        the final parameter to define the character that determines what
    C is the string value used as the word separater.


        separates words.  Ex:
    Ex:


        Str := 'Hello this is a test';
    Str := 'Hello this is a test';


        WriteLn ('Str has ' + Int2Str(WordCount(Str, ' ')) + ' words in it.');
    WriteLn('The second word was: ' + WordGet(2, Str, ' '));


   Function WORDGET(I : Integer, S, C : String) : String
Function WordPos (I : Integer; S, C : String ) : Integer


        returns the actual word at a specific word count.
    Function WordPos returns the character position in the string where


        S is the inputted string value.
    specific word is located.


        I is the numerical value of the position where the word can be found.
    S = Inputted string value


        C is the string value used as the word separater.
    I = Index value of the the desired word within S


        Ex:
    C = String value of the word separater.


        Str := 'Hello this is a test';
    Ex:


        WriteLn('The second word was: ' + WordGet(2, Str, ' '));
    Str := 'Hello this is a test';


   Function WordPos (I : Integer; S, C : String ) : Integer
    WriteLn ('Second word is at: ' + Int2Str(WordPos(2, Str, ' ')));


        Function WordPos returns the character position in the string where
    See Also : WordCount, WordGet


        specific word is located.
<nowiki>-----------------------------------------------------------------------</nowiki>


        S = Inputted string value
File Accessing Functions and Procedures


        I = Index value of the the desired word within S
<nowiki>-----------------------------------------------------------------------</nowiki>


        C = String value of the word separater.
Function FEOF (Handle) : Boolean


        Ex:
    This function will return true if the file position of an opened


        Str := 'Hello this is a test';
    file is at the End Of the File (EOF).  The passed Handle value is


        WriteLn ('Second word is at: ' + Int2Str(WordPos(2, Str, ' ')));
    the file number of the already opened file.


        See Also : WordCount, WordGet
    Example:


   -----------------------------------------------------------------------
    Var Str : String


   File Accessing Functions and Procedures
    Var Fpt : File


   -----------------------------------------------------------------------
    FOpen (1, Text, Reset, 'BLAH.TXT')


   Function FEOF (Handle) : Boolean
    While Not Eof(1)


        This function will return true if the file position of an opened
         FReadLn (1, Str)


        file is at the End Of the File (EOF).  The passed Handle value is
         WriteLn (Str)


        the file number of the already opened file.
    End


        Example:
    FClose (1)


        Var Str : String
    The above example will open a text file under the filename of


        Var Fpt : File
    BLAH.TXT.  The WHILE loop is used to repeat the code until the


        FOpen (1, Text, Reset, 'BLAH.TXT')
    EOF (end of file) is reached.  The FCLOSE statement will close


        While Not Eof(1)
    the file after it is done being accessed.


             FReadLn (1, Str)
    The result of the above example will be (in pseudocode):


             WriteLn (Str)
    1. Open text file.


        End
    2. If not at the end of file, run this code:


        FClose (1)
        3. Read line from text file into string variable


        The above example will open a text file under the filename of
        4. Print line read from text file to the screen.


        BLAH.TXT.  The WHILE loop is used to repeat the code until the
        5. Goto 2.


        EOF (end of file) is reached.  The FCLOSE statement will close
    6. Close the text file.


        the file after it is done being accessed.
    So the above example will basically write the entire text file to


        The result of the above example will be (in pseudocode):
    the screen.


        1. Open text file.
Procedure FCLOSE (File)


        2. If not at the end of file, run this code:
    This procedure closes an already opened file.  The passed Handle


                3. Read line from text file into string variable
    value is the file number of the opened file.  All files which


                4. Print line read from text file to the screen.
    are opened MUST be closed after they are not being accessed any


                5. Goto 2.
    more.


        6. Close the text file.
    For example:


        So the above example will basically write the entire text file to
    Var Fptr : File


        the screen.
    fAssign  (Fptr, 'BLAH.TXT', 66)


   Procedure FCLOSE (File)
    fReWrite (Fptr)


        This procedure closes an already opened file.  The passed Handle
    <nowiki><Code to access file goes here></nowiki>


        value is the file number of the opened file.  All files which
    fClose (Fptr)


        are opened MUST be closed after they are not being accessed any
    The above example opens a file using the FOPEN procedure.  When


        more.
    the file has been opened successfully, it can be accessed in


        For example:
    various ways using the file I/O functions.  Afterwards, it MUST


        Var Fptr : File
    be closed using the FCLOSE procedure as shown above.


        fAssign  (Fptr, 'BLAH.TXT', 66)
Function FILECOPY (Source: String, Dest: String) : Boolean


        fReWrite (Fptr)
    This function will copy a file from the specified source location


        <nowiki><Code to access file goes here></nowiki>
    to the specified destination location.  The function will return


        fClose (Fptr)
    as TRUE if the file was copied successfully, or FALSE if an error


        The above example opens a file using the FOPEN procedure.  When
    occured.  Note:  The file which is being copied should not already


        the file has been opened successfully, it can be accessed in
    be opened for File I/O by the program.


        various ways using the file I/O functions.  Afterwards, it MUST
    Example:


        be closed using the FCLOSE procedure as shown above.
    Write ('Copying C:\HELLO.TXT -> D:\HELLO.TXT: ')


   Function FILECOPY (Source: String, Dest: String) : Boolean
    If fileCopy ('C:\HELLO.TXT', 'D:\HELLO.TXT')


        This function will copy a file from the specified source location
         WriteLn ('OK')


        to the specified destination location.  The function will return
    Else


        as TRUE if the file was copied successfully, or FALSE if an error
         WriteLn ('ERROR')


        occured.  Note:  The file which is being copied should not already
    End


        be opened for File I/O by the program.
    The above example will attempt to copy the file "C:\HELLO.TXT" to


        Example:
    the destination of "D:\HELLO.TXT".  If the file is copied without


        Write ('Copying C:\HELLO.TXT -> D:\HELLO.TXT: ')
    any problems an "OK" will be printed to the screen.  If an error


        If fileCopy ('C:\HELLO.TXT', 'D:\HELLO.TXT')
    occured while copying, "ERROR" will be printed to the screen.


             WriteLn ('OK')
Procedure FILEERASE (FileName: String)


        Else
    This procedure is used to erase an existing file from the disk.


             WriteLn ('ERROR')
    The FileName variable is a string variable which contains the


        End
    file name which is to be erased.  The result of the FILEERASE


        The above example will attempt to copy the file "C:\HELLO.TXT" to
    procedure can be checked by checking the DOSERROR function.


        the destination of "D:\HELLO.TXT".  If the file is copied without
    DOSERROR will return a 0 if successful or a 2 if an error occured.


        any problems an "OK" will be printed to the screen.  If an error
    Example:


        occured while copying, "ERROR" will be printed to the screen.
    FileErase ('C:\HELLO.TXT')


   Procedure FILEERASE (FileName: String)
    The above example will erase the file "C:\HELLO.TXT" if it exists.


        This procedure is used to erase an existing file from the disk.
Function FILEEXIST (FileName: String) : Boolean


        The FileName variable is a string variable which contains the
    The above function will check to see if a file exists, and return


        file name which is to be erased.  The result of the FILEERASE
    TRUE if it does.  The passed FileName string if the path and file


        procedure can be checked by checking the DOSERROR function.
    name of the file to check.  This file should not already be opened


        DOSERROR will return a 0 if successful or a 2 if an error occured.
    with the FOPEN procedure.


        Example:
    Example:


        FileErase ('C:\HELLO.TXT')
    If FileExist('BLAH.TXT') Then


        The above example will erase the file "C:\HELLO.TXT" if it exists.
         WriteLn ('BLAH.TXT exists.')


   Function FILEEXIST (FileName: String) : Boolean
    Else


        The above function will check to see if a file exists, and return
         WriteLn ('BLAH.TXT does NOT exist.')


        TRUE if it does.  The passed FileName string if the path and file
    The above example will check to see if the file "BLAH.TXT" exists


        name of the file to checkThis file should not already be opened
    and if it does, will output "BLAH.TXT exists" to the screenIf


        with the FOPEN procedure.
    BLAH.TXT does NOT exist, the output will be "BLAH.TXT does NOT


        Example:
    exist".


        If FileExist('BLAH.TXT') Then
Function FPOS (File) : LongInt


             WriteLn ('BLAH.TXT exists.')
    This function returns the current file position of an opened


        Else
    file.  The passed Handle is the file handle number used when the


             WriteLn ('BLAH.TXT does NOT exist.')
    file was opened.  The FilePos function only works for files that


        The above example will check to see if the file "BLAH.TXT" exists
    are opened as Binary, since Text files are read line by line.


        and if it does, will output "BLAH.TXT exists" to the screen.  If
    Example:


        BLAH.TXT does NOT exist, the output will be "BLAH.TXT does NOT
    Var Fptr : File


        exist".
    fAssign (Fptr, 'TEST.DAT', 66)


   Function FPOS (File) : LongInt
    fReset(Fptr)


        This function returns the current file position of an opened
    If IORESULT = 0 Then Begin


        file.  The passed Handle is the file handle number used when the
       If fPos(Fptr) = FSize(Fptr)


        file was opened.  The FilePos function only works for files that
          WriteLn ('END OF FILE.')


        are opened as Binary, since Text files are read line by line.
       End


        Example:
       fClose (fPtr)


        Var Fptr : File
    End


        fAssign (Fptr, 'TEST.DAT', 66)
    The above example opens the file "TEST.DAT" for binary and then


        fReset(Fptr)
    writes to the screen if the file position is at the end of the


        If IORESULT = 0 Then Begin
    file.  The above statement "fPos(Fptr) = fSize(Fptr)" is the same


           If fPos(Fptr) = FSize(Fptr)
    as "fEof(Fptr)" since it's stating "if the file position is equal to


              WriteLn ('END OF FILE.')
    the total file size, then we're at the end of the file."


           End
Function FSIZE (File) : LongInt


           fClose (fPtr)
    This function returns the total file size of an opened file.  The


        End
    passed Handle is the file handle number used when the file was


        The above example opens the file "TEST.DAT" for binary and then
    opened.  This function only works with files that have been opened


        writes to the screen if the file position is at the end of the
    as Binary since Text files are read line by line.


        file.  The above statement "fPos(Fptr) = fSize(Fptr)" is the same
    Example:


        as "fEof(Fptr)" since it's stating "if the file position is equal to
    Var Fptr : File


        the total file size, then we're at the end of the file."
    fAssign (Fptr, 'TEST.DAT', 66)


   Function FSIZE (File) : LongInt
    fReset(Fptr)


        This function returns the total file size of an opened file.  The
    If IoResult = 0 Then


        passed Handle is the file handle number used when the file was
        WriteLn ('This file is ', fSize(Fptr), ' bytes in size.')


        opened.  This function only works with files that have been opened
    fClose (Fptr)


        as Binary since Text files are read line by line.
    The above example opens the file "TEST.DAT", writes the size of


        Example:
    the file to the screen, and then closes the file.


        Var Fptr : File
Procedure FASSIGN (Fptr : File, Mask : String, Attr : Int)


        fAssign (Fptr, 'TEST.DAT', 66)
    This procedure opens a text or binary file for file operations.


        fReset(Fptr)
    Fptr  : The passed file pointer is the file reference, of type FILE


        If IoResult = 0 Then
    Mask  : The path and filename of the file to open, in string format.


            WriteLn ('This file is ', fSize(Fptr), ' bytes in size.')
    Attr  : File attributes to open.  See FINDFIRST for more info.  


        fClose (Fptr)
    EXAMPLE:


        The above example opens the file "TEST.DAT", writes the size of
    Var Fptr : File  


        the file to the screen, and then closes the file.
    fAssign (Fptr, 'BLAH.TXT', 66)


   Procedure FASSIGN (Fptr : File, Mask : String, Attr : Int)
    fReWrite (Fptr)


        This procedure opens a text or binary file for file operations.
    fWriteLn (Fptr, 'Hello World!')


        Fptr  : The passed file pointer is the file reference, of type FILE
    fClose (Fptr)


        Mask  : The path and filename of the file to open, in string format.
    The above example creates a text file under the name 'BLAH.TXT'.


        Attr  : File attributes to open.  See FINDFIRST for more info.  
    If BLAH.TXT already exists, it will be erased and replaced by a


        EXAMPLE:
    new BLAH.TXT file.  The FWriteLn writes the text "Hello World" to


        Var Fptr : File  
    the file, and then FClose closes the file.


        fAssign (Fptr, 'BLAH.TXT', 66)
Procedure FRESET (File)


        fReWrite (Fptr)
    This procedure moves the file pointer to the beginning of an already


        fWriteLn (Fptr, 'Hello World!')
    opened file.  This is useful for moving the file pointer to specific


        fClose (Fptr)
    spots in the file, without having to close and reopen the file.  The


        The above example creates a text file under the name 'BLAH.TXT'.
    file must have previously been opened by FASSIGN.


        If BLAH.TXT already exists, it will be erased and replaced by a
    Use IORESULT to determine if the freset command was successful.


        new BLAH.TXT file.  The FWriteLn writes the text "Hello World" to
    Var fPtr : File


        the file, and then FClose closes the file.
    fAssign(Fptr,CfgDataPath+'somefile.dat',66)


   Procedure FRESET (File)
    fReset(Fptr)


        This procedure moves the file pointer to the beginning of an already
    If IORESULT = 0 Then Begin


        opened file.  This is useful for moving the file pointer to specific
       WriteLn('somefile.dat is opened for use!')


        spots in the file, without having to close and reopen the file.  The
       WriteLn('closing somefile.dat!')


        file must have previously been opened by FASSIGN.
       fClose(Fptr)


        Use IORESULT to determine if the freset command was successful.
    End Else


        Var fPtr : File
       WriteLn('Unable to open somefile.dat')


        fAssign(Fptr,CfgDataPath+'somefile.dat',66)
     


        fReset(Fptr)
Procedure FREWRITE(File)


        If IORESULT = 0 Then Begin
    This procedure will this will erase an existing file and recreate it,


           WriteLn('somefile.dat is opened for use!')
    leaving the file position at the beginning of the file.  If the


           WriteLn('closing somefile.dat!')
    file does not already exist, MPL will create the file.  The file must


           fClose(Fptr)
    have previously been opened by FASSIGN.


        End Else
Procedure FSEEK (Fptr: File, Position: LongInt)


           WriteLn('Unable to open somefile.dat')
    This procedure seeks to a file position in a binary file.  It


         
    will only work on binary files, not text file.


   
    Fptr : The passed file pointer value of type FILE


   Procedure FREWRITE(File)
    Position : This is the position where FSEEK will seek to.


        This procedure will this will erase an existing file and recreate it,
    EXAMPLE:


        leaving the file position at the beginning of the file.  If the
    Var Str : String


        file does not already exist, MPL will create the file.  The file must
    Var Fptr: File


        have previously been opened by FASSIGN.
    Str := 'Hello World!'


   Procedure FSEEK (Fptr: File, Position: LongInt)
    fAssign   (Fptr, 'BLAH.DAT',66)


        This procedure seeks to a file position in a binary file.  It
    fSeek     (Fptr, FileSize(1))


        will only work on binary files, not text file.
    fWriteRec (Fptr, Str, 12)


        Fptr : The passed file pointer value of type FILE
    fClose    (Fptr)


        Position : This is the position where FSEEK will seek to.
    The above example opens an already existing file under the name


        EXAMPLE:
    'BLAH.DAT'.  Using FSEEK, it will seek to the end of the file,


        Var Str : String
    so that "Hello World" can be added as the last record.


        Var Fptr: File
Procedure FREAD (File, Str, Int)


        Str := 'Hello World!'
    This procedure is used to read binary data from a file.


        fAssign   (Fptr, 'BLAH.DAT',66)
    Type FileInfo = record


        fSeek     (Fptr, FileSize(1))
       Index : Integer


        fWriteRec (Fptr, Str, 12)
<nowiki>       Name  : String [50]</nowiki>


        fClose    (Fptr)
       Data  : Integer


        The above example opens an already existing file under the name
    End


        'BLAH.DAT'.  Using FSEEK, it will seek to the end of the file,
    Var fptr : File


        so that "Hello World" can be added as the last record.
    Var info : FileInfo


   Procedure FREAD (File, Str, Int)
    Var Recno: Integer = 3


        This procedure is used to read binary data from a file.
    fAssign(Fptr,'FILE.DAT',66) // Open the file


        Type FileInfo = record
    fReset(Fptr) // Reset to the beginning of the file


           Index : Integer
   If IoResult = 0 Then Begin  // If successful...


<nowiki>           Name  : String [50]</nowiki>
      fSeek(Fptr,(Recno-1)*SizeOf(Info)) // Go to 3rd record in the file


           Data  : Integer
      If Not fEof(Fptr) Then // If the 3rd record is there...


        End
         fRead(Fptr,Info,SizeOf(Info)) // Read the record


        Var fptr : File
         // Optionally, use FreadRec(Fptr,Info) when reading record types.


        Var info : FileInfo
    End


        Var Recno: Integer = 3
    fClose(Fptr) // close the file


        fAssign(Fptr,'FILE.DAT',66) // Open the file
Procedure FREADLN(File,Str)


        fReset(Fptr) // Reset to the beginning of the file
    This procedure will read string data from a text file.


           If IoResult = 0 Then Begin  // If successful...
    Var fptr : File


          fSeek(Fptr,(Recno-1)*SizeOf(Info)) // Go to 3rd record in the file
    Var Str  : String


          If Not fEof(Fptr) Then // If the 3rd record is there...
    fAssign(Fptr,'somefile.txt',66)


             fRead(Fptr,Info,SizeOf(Info)) // Read the record
    fReset(Fptr)


             // Optionally, use FreadRec(Fptr,Info) when reading record types.
    If IoResult = 0 Then Begin


        End
       While Not fEof(Fptr) Do Begin


        fClose(Fptr) // close the file
          FReadLn(Fptr,Str)


   Procedure FREADLN(File,Str)
          WriteLn(Str)


        This procedure will read string data from a text file.
       End


        Var fptr : File
       fClose(Fptr)


        Var Str  : String
    End


        fAssign(Fptr,'somefile.txt',66)
Procedure FWRITE (File, Str, Int)


        fReset(Fptr)
    This procedure is used to write binary data to a file.


        If IoResult = 0 Then Begin
    Type FileInfo = record


           While Not fEof(Fptr) Do Begin
       Index : Integer


              FReadLn(Fptr,Str)
<nowiki>       Name  : String [50]</nowiki>


              WriteLn(Str)
       Data  : Integer


           End
    End


           fClose(Fptr)
    Var fptr : File


        End
    Var info : FileInfo


   Procedure FWRITE (File, Str, Int)
    info.Index:=1


        This procedure is used to write binary data to a file.
    info.Data:=33


        Type FileInfo = record
    info.Name:='newname'


           Index : Integer
    fAssign(Fptr,'FILE.DAT',66)


<nowiki>           Name  : String [50]</nowiki>
    fReWrite(Fptr)


           Data  : Integer
    fWrite(Fptr,Info,SizeOf(Info))


        End
    fClose(Fptr)


        Var fptr : File
Procedure FWRITELN(File,Str)


        Var info : FileInfo
    This procedure is used to save string data to a text file.


        info.Index:=1
    Var Fptr : File


        info.Data:=33
    Var Str  : String = 'I am a string value!'


        info.Name:='newname'
    fAssign(Fptr,'flatfile.txt',66)


        fAssign(Fptr,'FILE.DAT',66)
    fReset(Fptr)


        fReWrite(Fptr)
    If IoRESULT = 0 Then Begin


        fWrite(Fptr,Info,SizeOf(Info))
       // File already exists.


        fClose(Fptr)
       // Seek to the end of the file.  aka append to the file


    Procedure FWRITELN(File,Str)
       fSeek(Fptr,FSize(Fptr))


        This procedure is used to save string data to a text file.
    End Else Begin


        Var Fptr : File
       // File is not yet created.  Create it now.


        Var Str  : String = 'I am a string value!'
       fReWrite(Fptr)


        fAssign(Fptr,'flatfile.txt',66)
    End


        fReset(Fptr)
    fWriteLn(Fptr,Str)


        If IoRESULT = 0 Then Begin
    fClose(Fptr)


           // File already exists.
Function SIZEOF (Type) : LongInt


           // Seek to the end of the file.  aka append to the file
    This function will take any named data type as input, and return


           fSeek(Fptr,FSize(Fptr))
    the size of the data.


        End Else Begin
    Type TypeOfData = Record


           // File is not yet created.  Create it now.
      N : Integer


           fReWrite(Fptr)
      L : Real


        End
      V : LongInt


        fWriteLn(Fptr,Str)
<nowiki>      Q : String [32] </nowiki>


        fClose(Fptr)
    End


   Function SIZEOF (Type) : LongInt
    Var I : Integer


        This function will take any named data type as input, and return
<nowiki>    Var S : String [50]</nowiki>


        the size of the data.
    Var R : Real


        Type TypeOfData = Record
    Var T : TypeofData


          N : Integer
    WriteLn('Size Of I = '+Int2Str(SizeOf(I)))


          L : Real
    WriteLn('Size Of S = '+Int2Str(SizeOf(S)))


          V : LongInt
    WriteLn('Size Of R = '+Int2Str(SizeOf(R)))


<nowiki>          Q : String [32] </nowiki>
    WriteLn('Size Of T = '+Int2Str(SizeOf(T)))


        End
<nowiki>-----------------------------------------------------------------------</nowiki>


        Var I : Integer
BBS Related Functions and Procedures


<nowiki>        Var S : String [50]</nowiki>
<nowiki>-----------------------------------------------------------------------</nowiki>


        Var R : Real
Function ACS (S: String) : Boolean


        Var T : TypeofData
    This function processes an ACS string and returns true if the user


        WriteLn('Size Of I = '+Int2Str(SizeOf(I)))
    has passed.


        WriteLn('Size Of S = '+Int2Str(SizeOf(S)))
    Example:


        WriteLn('Size Of R = '+Int2Str(SizeOf(R)))
    If ACS('s10g1') Then


        WriteLn('Size Of T = '+Int2Str(SizeOf(T)))
         WriteLn ('You have access to this.')


   -----------------------------------------------------------------------
    Else


   BBS Related Functions and Procedures
         WriteLn ('Sorry, you do not have access.')


   -----------------------------------------------------------------------
    The above example checks to see if the user passes the ACS string


   Function ACS (S: String) : Boolean
    of "s10g1" and prints the result to the screen.


        This function processes an ACS string and returns true if the user
Function DATESTR (DT: LongInt, dType: Byte) : Integer


        has passed.
    This function will take a packed datetime number and convert it to


        Example:
    a date string.  The dType parameter is used to set the format of the


        If ACS('s10g1') Then
    date which is returned.  Valid types are:


             WriteLn ('You have access to this.')
         UserDateType  = Returns date in the users date format


        Else
         1 = Returns date in format: MM/DD/YY


             WriteLn ('Sorry, you do not have access.')
         2 = Returns date in format: DD/MM/YY


        The above example checks to see if the user passes the ACS string
         3 = Returns date in format: YY/DD/MM


        of "s10g1" and prints the result to the screen.
    Example:


   Function DATESTR (DT: LongInt, dType: Byte) : Integer
    GetThisUser


        This function will take a packed datetime number and convert it to
    WriteLn ('Welcome.  You last called on ', DateStr(UserLast))


        a date string.  The dType parameter is used to set the format of the
    The above example loads the currently logged in user's information


        date which is returned.  Valid types are:
    into the USER variables using GETTHISUSER, then displays the last


             UserDateType  = Returns date in the users date format
    time the user has called to the screen using the DATESTR procedure.


             1 = Returns date in format: MM/DD/YY
Function DATETIME : LongInt


             2 = Returns date in format: DD/MM/YY
    This function returns the current Date and Time in the packed


             3 = Returns date in format: YY/DD/MM
    format.  DATESTR and TIMESTR can be used to convert this value


        Example:
    into strings.


        GetThisUser
    Example:


        WriteLn ('Welcome.  You last called on ', DateStr(UserLast))
    WriteLn ('Current Date: ', DateStr(DateTime), 0)


        The above example loads the currently logged in user's information
    WriteLn ('Current Time: ', TimeStr(DateTime), 1)


        into the USER variables using GETTHISUSER, then displays the last
    The above example outputs the current date and time to the screen


        time the user has called to the screen using the DATESTR procedure.
    using the DATESTR and TIMESTR functions.  The DateTime function


   Function DATETIME : LongInt
    which is passed to DATESTR and TIMESTR, contains the current date


        This function returns the current Date and Time in the packed
    and time in the packed format.


        format.  DATESTR and TIMESTR can be used to convert this value
Function DIREXIST (S : String) : Boolean


        into strings.
    This function returns TRUE or FALSE if a directory exists.


        Example:
    If DirExist('C:/MYSTIC/TEMP46') Then


        WriteLn ('Current Date: ', DateStr(DateTime), 0)
       WriteLn('Dir C:/MYSTIC/TEMP46 exists!')


        WriteLn ('Current Time: ', TimeStr(DateTime), 1)
    Else


        The above example outputs the current date and time to the screen
       WriteLn('Dir C:/MYSTIC/TEMP46 does not exist!')


        using the DATESTR and TIMESTR functions.  The DateTime function
Procedure DISPFILE (FN: String)


        which is passed to DATESTR and TIMESTR, contains the current date
    This procedure displays a text or ANSI file to the screen.  If a


        and time in the packed format.
    path not included in the passed filename, Mystic will look for


  Function DIREXIST (S : String) : Boolean
    the file in the language text file directory.  If no file


    extension is provided in the passed file name, Mystic will display


        This function returns TRUE or FALSE if a directory exists.
    the correct file according to the user's graphics settings


        If DirExist('C:/MYSTIC/TEMP46') Then
    (ie .ANS for ANSI, .ASC for non-ansi).


           WriteLn('Dir C:/MYSTIC/TEMP46 exists!')
    Example:


        Else
    DispFile ('WELCOME')


           WriteLn('Dir C:/MYSTIC/TEMP46 does not exist!')
    The above example will display the text file "WELCOME" from the


  Procedure DISPFILE (FN: String)
    language text file directory.  Since there is no file extension


        This procedure displays a text or ANSI file to the screen.  If a
    provided, Mystic will display "WELCOME.ANS" or "WELCOME.ASC"


        path not included in the passed filename, Mystic will look for
    depending on what the user's terminal settings are.


        the file in the language text file directory.  If no file
Procedure FILLCHAR (R : Record; S : Integer; V : Value )


        extension is provided in the passed file name, Mystic will display
    Fillchar fills the memory starting at X with Count bytes or


        the correct file according to the user's graphics settings
    characters with value equal to Value.


        (ie .ANS for ANSI, .ASC for non-ansi).
    type


        Example:
    myuserrecord = record


        DispFile ('WELCOME')
<nowiki>      username  : string[30];</nowiki>


        The above example will display the text file "WELCOME" from the
<nowiki>      somevalue : array[1..5] of byte;</nowiki>


        language text file directory.  Since there is no file extension
    end;


        provided, Mystic will display "WELCOME.ANS" or "WELCOME.ASC"
    var


        depending on what the user's terminal settings are.
      u : myuserrecord;


  Procedure FILLCHAR (R : Record; S : Integer; V : Value )
    begin


        Fillchar fills the memory starting at X with Count bytes or
      fillchar(u, sizeof(u), #0);


        characters with value equal to Value.
    end.


        type
Procedure GETCFG


        myuserrecord = record
    This procedure will load the current configuration data into the


<nowiki>          username  : string[30];</nowiki>
        CFG variables.  The "USES CFG" command must be used at the start


<nowiki>          somevalue : array[1..5] of byte;</nowiki>
        of your program for GETCFG to work.  The following variables will


        end;
        be loaded:


        var
    CFGSYSPATH     : System Path


          u : myuserrecord;
    CFGDATAPATH    : Data Path


        begin
    CFGMSGSPATH    : Message Base Path


          fillchar(u, sizeof(u), #0);
    CFGPROTPATH    : Protocol Path


        end.
    CFGQWKPATH     : Local QWK Path


  Procedure GETCFG
    CFGMPEPATH     : Script (MPE) Path


        This procedure will load the current configuration data into the
    CFGATTPATH     : File Attach Path


                CFG variables.  The "USES CFG" command must be used at the start
    CFGLOGSPATH    : System Logs Path


                of your program for GETCFG to work.  The following variables will
    CFGTEXTPATH    : Text Files Path (for the current language)


                be loaded:
    CFGTEMPPATH    : Temp path for the current node


        CFGSYSPATH     : System Path
    CFGMENUPATH    : Menu Files Path (for the current language)


        CFGDATAPATH    : Data Path
    CFGTIMEOUT     :  


        CFGMSGSPATH    : Message Base Path
    CFGSEEINVIS    : Gives the "See Invisible" ACS value


        CFGPROTPATH    : Protocol Path
    CFGTNNODES     : Number of max telnet nodes to allow


        CFGQWKPATH     : Local QWK Path
    CFGNETDESC[1..30]     : Give the network descriptions.


        CFGMPEPATH     : Script (MPE) Path
    Example:


        CFGATTPATH     : File Attach Path
        Uses CFG


        CFGLOGSPATH    : System Logs Path
        GetCFG


        CFGTEXTPATH    : Text Files Path (for the current language)
    WriteLn ('Mystic BBS is installed in ', CfgSysPath)


        CFGTEMPPATH    : Temp path for the current node
    The above example will load the configuration into the CFG


        CFGMENUPATH    : Menu Files Path (for the current language)
    variables, and then print the directory where Mystic BBS is


        CFGTIMEOUT     :
    installed in to the screen.


        CFGSEEINVIS    : Gives the "See Invisible" ACS value
Function GETATTRXY (X, Y : Byte) : Byte


        CFGTNNODES     : Number of max telnet nodes to allow
    This function returns the attribute of the character at position


        CFGNETDESC[1..30]     : Give the network descriptions.
    XY on the user's screen:


        Example:
    Var Attr : Byte;


                Uses CFG
    Attr := GetAttrXY(1, 1);


                GetCFG
    WriteLn ('The attribure of the character at 1,1 is: ' + strI2S(Attr));


        WriteLn ('Mystic BBS is installed in ', CfgSysPath)
Function GETCHARXY (X, Y : Byte) : Char


        The above example will load the configuration into the CFG
    This function returns the character located on the user's


        variables, and then print the directory where Mystic BBS is
    screen at the XY location.


        installed in to the screen.
    Var Ch : Char;


  Function GETATTRXY (X, Y : Byte) : Byte
    Ch := GetCharXY(1, 1);


        This function returns the attribute of the character at position
    WriteLn('The user has the following character at 1,1: ' + Ch);


        XY on the user's screen:
    This kind of stuff could allow you to create MPL-based custom screen


        Var Attr : Byte;
    effects like TheDraw used to have, except for on-the-fly with whatever


        Attr := GetAttrXY(1, 1);
    is on the user's screen.


        WriteLn ('The attribure of the character at 1,1 is: ' + strI2S(Attr));
Function GETMBASE (N : Word) : Boolean


  Function GETCHARXY (X, Y : Byte) : Char
    This procedure will read message base data into the MBASE variables.


        This function returns the character located on the user's
    The supplied N is the record number to read.  The function will


        screen at the XY location.
    return TRUE if the record was read successfully, or FALSE if the


        Var Ch : Char;
        record was not read.  The "USES MBASE" command must be called at


        Ch := GetCharXY(1, 1);
        the start of your program for the MBASE functions to work


        WriteLn('The user has the following character at 1,1: ' + Ch);
        correctly.


        This kind of stuff could allow you to create MPL-based custom screen
    The following MBASE variables will be set when a record is read:


        effects like TheDraw used to have, except for on-the-fly with whatever
    Variable Name   Type     Description


        is on the user's screen.
    -------------------------------------------------------------------


  Function GETMBASE (N : Word) : Boolean
    MBASENAME      String    Name


        This procedure will read message base data into the MBASE variables.
   MBASEACS       String    ACS level


        The supplied N is the record number to read.  The function will
   MBASERACS      String    Read ACS level


        return TRUE if the record was read successfully, or FALSE if the
   MBASEPACS      String    Post ACS level


                record was not read.  The "USES MBASE" command must be called at
   MBASESACS      String    SysOp ACS level


                the start of your program for the MBASE functions to work
   MBASEINDEX     Integer   Index number (*NEVER* change this)


                correctly.
    Example:


        The following MBASE variables will be set when a record is read:
    Var A Word


        Variable Name   Type     Description
    A := 1


        -------------------------------------------------------------------
    While GetMBase Do


        MBASENAME      String    Name
    Begin


           MBASEACS       String    ACS level
         WriteLn ('Base name: ', MBaseName)


           MBASERACS      String    Read ACS level
         A := A + 1


           MBASEPACS      String    Post ACS level
    End


           MBASESACS      String    SysOp ACS level
    The above example will list all available message base systems on


           MBASEINDEX     Integer   Index number (*NEVER* change this)
    the BBS.


        Example:
Function GETMBASESTATS (Base : LongInt; B1, B2 : Boolean; Tot, New, Yours : LongInt) : Boolean


        Var A Word
     This can be used as a function or a procedure (returning true if


        A := 1
     successful).  It takes 6 parameters.


        While GetMBase Do
     #1: Message base number


        Begin
     #2: Exclude messages FROM the current user in stats


             WriteLn ('Base name: ', MBaseName)
     #3: Exclude messages TO the current user that have already been read


             A := A + 1
     #4: Total messages (this is a VAR parameter)


        End
     #5: New messages (this is a VAR parameter)


        The above example will list all available message base systems on
     #6: New messages to you (this is a VAR parameter)


        the BBS.
     Example:


   Function GETMBASESTATS (Base : LongInt; B1, B2 : Boolean; Tot, New, Yours : LongInt) : Boolean
     uses mbase;


         This can be used as a function or a procedure (returning true if
     var


         successful).  It takes 6 parameters.
       count, total, new, yours : longint;


         #1: Message base number
     begin


         #2: Exclude messages FROM the current user in stats
     count := 1;  //start @1 to skip email base


         #3: Exclude messages TO the current user that have already been read
     while getmbase(count) do begin


         #4: Total messages (this is a VAR parameter)
       getmbstats(count, true, true, total, new, yours);


         #5: New messages (this is a VAR parameter)
       writeln('base       : ' + mbasename);


         #6: New messages to you (this is a VAR parameter)
       writeln('total msgs : ' + int2str(total));


         Example:
       writeln('new msgs   : ' + int2str(new));


         uses mbase;
       writeln('your msgs  : ' + int2str(yours));


         var
       writeln(<nowiki>''</nowiki>);


           count, total, new, yours : longint;
       count := count + 1


         begin
     end;


         count := 1;  //start @1 to skip email base
Function GETMBASETOTAL (Compress : Boolean) : LongInt


         while getmbase(count) do begin
    This function returns the total message bases on the system.  If


           getmbstats(count, true, true, total, new, yours);
    Compressed is true, then it will return the total number of message


           writeln('base       : ' + mbasename);
    bases the user has access to (slower to calculate).  If it is false,


           writeln('total msgs : ' + int2str(total));
    it returns the raw total number of bases on the system.


           writeln('new msgs   : ' + int2str(new));
Function GETPROMPT (N : Word) : String


           writeln('your msgs  : ' + int2str(yours));
    This function will return a prompt from the current user's language


           writeln(<nowiki>''</nowiki>);
    file.  The passed N varliable is the prompt number to return.


           count := count + 1
    Example:


         end;
    WriteLn(GetPrompt(1))


   Function GETMBASETOTAL (Compress : Boolean) : LongInt
    The above example writes prompt #1 from the user's currently


        This function returns the total message bases on the system.  If
    selected language file to the screen.


        Compressed is true, then it will return the total number of message
Procedure GETSCREENINFO (I, X, Y, Attr : Integer)


        bases the user has access to (slower to calculate).  If it is false,  
    This allows you to read Mystic's internal ScreenInfo codes,  


        it returns the raw total number of bases on the system.
    used in Templates - so your MPLs can easily have templates


  Function GETPROMPT (N : Word) : String
    just like Mystic!  These are the |!X codes.


        This function will return a prompt from the current user's language
Var


        file.  The passed N varliable is the prompt number to return.
  X, Y, Attr : Byte;


        Example:
Begin


        WriteLn(GetPrompt(1))
  GetScreenInfo(1, X, Y, Attr);


        The above example writes prompt #1 from the user's currently
  WriteLn('The value of the !1 MCI code was:');


        selected language file to the screen.
  WriteLn('   X: ' + Int2Str(X));


  Procedure GETSCREENINFO (I, X, Y, Attr : Integer)  
  WriteLn('   Y: ' + Int2Str(Y));


        This allows you to read Mystic's internal ScreenInfo codes,
  WriteLn('Attr: ' + Int2Str(Attr));


        used in Templates - so your MPLs can easily have templates
End;


        just like Mystic!  These are the |!X codes.
Function GETUSER (N: Integer) : Boolean


    Var
    This procedure will read user data into the USER variables.  The


      X, Y, Attr : Byte;
    supplied N is the record number to read.  The function returns


    Begin
    true if the record was read, or false if a record was not read.


      GetScreenInfo(1, X, Y, Attr);
    The following USER variables will be set when a record is read:


      WriteLn('The value of the !1 MCI code was:');
    Variable Name   Type     Description


      WriteLn('   X: ' + Int2Str(X));
    -------------------------------------------------------------------


      WriteLn('   Y: ' + Int2Str(Y));
    USERDELETED     Boolean  Is the user marked as deleted?


      WriteLn('Attr: ' + Int2Str(Attr));
    USERNAME        String   User's real name.


    End;
    USERALIAS       String   User's BBS alias.


  Function GETUSER (N: Integer) : Boolean
    USERPASSWORD    String   User's password.


        This procedure will read user data into the USER variables.  The
    USERADDRESS     String   User's street address.


        supplied N is the record number to read.  The function returns
    USERCITY        String   User's City/State.


        true if the record was read, or false if a record was not read.
    USERBIRTHDAY    String   User's birth date.


        The following USER variables will be set when a record is read:
    USERSEX         Char     User's gender (M = Male, F = FeMale).


        Variable Name   Type     Description
    USERSEC         Byte     User's security level (0-255).


        -------------------------------------------------------------------
    USERFIRSTON     LongInt  User's date/time of first call to the BBS.


        USERDELETED     Boolean  Is the user marked as deleted?
                             This is stored in the packed date format


        USERNAME        String   User's real name.
                             so in order to display the date & time,


        USERALIAS       String   User's BBS alias.
                             the functions of DATESTR and TIMESTR need


        USERPASSWORD    String   User's password.
                             to be used.


        USERADDRESS     String   User's street address.
    USERLASTON      LongInt  User's date/time of the last call to the


        USERCITY        String   User's City/State.
                             BBS.  This is also stored in a packed date


        USERBIRTHDAY    String   User's birth date.
                             format, so the same rules for USERFIRST


        USERSEX         Char     User's gender (M = Male, F = FeMale).
                             apply to this.


        USERSEC         Byte     User's security level (0-255).
    -------------------------------------------------------------------


        USERFIRSTON     LongInt  User's date/time of first call to the BBS.
    Example:


                                 This is stored in the packed date format
    Var A Integer


                                 so in order to display the date & time,
    A := 1


                                 the functions of DATESTR and TIMESTR need
    While GetUser(A) Do


                                 to be used.
    Begin


        USERLASTON      LongInt  User's date/time of the last call to the
         WriteLn ('User Alias: ', UserAlias)


                                 BBS.  This is also stored in a packed date
         A := A + 1


                                 format, so the same rules for USERFIRST
    End


                                 apply to this.
    The above example will list all user accounts on the BBS system.


        -------------------------------------------------------------------
Procedure GETTHISUSER;


        Example:
    This procedure loads the user information for the currently


        Var A Integer
    logged in user into the USER variables.  See the GETUSER function


        A := 1
    for a reference of the USER variables.


        While GetUser(A) Do
    Example:


        Begin
    GetThisUser


             WriteLn ('User Alias: ', UserAlias)
    WriteLn ('Welcome to this BBS, ', UserAlias)


             A := A + 1
    WriteLn ('You have called ', UserCalls, ' times!')


        End
    The above example will load the currently logged in user


        The above example will list all user accounts on the BBS system.
    information into the user variables, then display a line of


  Procedure GETTHISUSER;
    text welcoming them to the BBS.


        This procedure loads the user information for the currently
Function GRAPHICS : Byte


        logged in user into the USER variables.  See the GETUSER function
    This function returns the user's current graphics mode in


        for a reference of the USER variables.
    numerical format:


        Example:
         0 = ASCII graphics mode


        GetThisUser
         1 = ANSI graphics mode


        WriteLn ('Welcome to this BBS, ', UserAlias)
    Example:


        WriteLn ('You have called ', UserCalls, ' times!')
    If Graphics = 1 Then


        The above example will load the currently logged in user
         WriteLn ('ANSI graphics')


        information into the user variables, then display a line of
    Else


        text welcoming them to the BBS.
         WriteLn ('ASCII graphics')


  Function GRAPHICS : Byte
    The above example will print the user's current graphics mode


        This function returns the user's current graphics mode in
    to the screen.  If the user has ANSI (graphics mode 1), "ANSI


        numerical format:
    graphics" will be printed.  If the user does not have ANSI


             0 = ASCII graphics mode
    (graphics mode 0), "ASCII graphics" will be printed to the screen.


             1 = ANSI graphics mode
Procedure HANGUP


        Example:
    This procedure will stop the program immediately, hangup up on the


        If Graphics = 1 Then
    user, and return Mystic BBS to the waiting for caller screen.


             WriteLn ('ANSI graphics')
    Example:


        Else
    If InputYN ('Do you want to hangup now? ') Then


             WriteLn ('ASCII graphics')
         HangUp


        The above example will print the user's current graphics mode
    The above example will prompt the user with a Yes/No question


        to the screen.  If the user has ANSI (graphics mode 1), "ANSI
    asking "Do you want to hangup now?" and if the user responds


        graphics" will be printed.  If the user does not have ANSI
    "Yes", they will be logged off the BBS using the HangUp command.


        (graphics mode 0), "ASCII graphics" will be printed to the screen.
Function JustFile (S : String) : String


  Procedure HANGUP
    This function takes a string arguement and returns only the


        This procedure will stop the program immediately, hangup up on the
    filename:


        user, and return Mystic BBS to the waiting for caller screen.
    WriteLn ('This MPX filename is: ' + JustFile(ProgName));


        Example:
Function JustFileName (S : String) : String


        If InputYN ('Do you want to hangup now? ') Then
    This function  takes a string arguement and returns only the base


             HangUp
    filename (ie, not the extension so it basically just removes a file


        The above example will prompt the user with a Yes/No question
    extension).  This does not remove a path, JustFile does that.


        asking "Do you want to hangup now?" and if the user responds
    WriteLn ('This MPX filename is: ' + JustFileName(ProgName));


        "Yes", they will be logged off the BBS using the HangUp command.
Function JustPath (S : String) : String


  Function JustFile (S : String) : String
    This function takes a string arguement and returns only the


        This function takes a string arguement and returns only the
    path (including the trailing backslash).


        filename:
    Ex:


        WriteLn ('This MPX filename is: ' + JustFile(ProgName));
    WriteLn ('This MPX is located in ' + JustPath(ProgName));


  Function JustFileName (S : String) : String
Function LOCAL : Boolean


   
    This function returns TRUE if the user is logged into the BBS


        This function  takes a string arguement and returns only the base
    system locally.  It will return FALSE if the user is connected


        filename (ie, not the extension so it basically just removes a file
    via a remote location.


        extension).  This does not remove a path, JustFile does that.
    Example:


        WriteLn ('This MPX filename is: ' + JustFileName(ProgName));
    If Local Then


  Function JustPath (S : String) : String
      WriteLn ('Local caller detected.')


        This function takes a string arguement and returns only the
    Else


        path (including the trailing backslash).
      WriteLn ('Remote caller detected.')


Function MSGEDITOR(0,Int,Int,Int,Bool,Str,Str) : Bool


        Ex:
Procedure MSGEDITSET(Int,Str)


        WriteLn ('This MPX is located in ' + JustPath(ProgName));
Procedure MSGEDITGET(Int,Str)


  Function LOCAL : Boolean
     Added 3 new MPL functions: MsgEditor, MsgEditSet, MsgEditGet.  These


        This function returns TRUE if the user is logged into the BBS
     allow access to the internal Mystic msg editor (line and/or full)


        system locally.  It will return FALSE if the user is connected
     from within MPL.  It even allows you to define wrap position and


        via a remote location.
     template to completely make it look like its not the Mystic editor!


        Example:
     As a little hint the MsgEditSet and MsgEditGet stuff could be used to


        If Local Then
     post process message text on posts.  Like say for example you wanted


          WriteLn ('Local caller detected.')
     to write a MPL that allows users to add Tag lines, you could do that


        Else
     by replacing the "Saving message..." prompt and using those two in


          WriteLn ('Remote caller detected.')
     order to modify the text before it is saved by Mystic!


    Function MSGEDITOR(0,Int,Int,Int,Bool,Str,Str) : Bool
     Rather than trying to explain it all, here is an example of all 3:


    Procedure MSGEDITSET(Int,Str)
Var


    Procedure MSGEDITGET(Int,Str)
  Lines    : Integer = 0;


         Added 3 new MPL functions: MsgEditor, MsgEditSet, MsgEditGet.  These
  WrapPos  : Integer = 79;


         allow access to the internal Mystic msg editor (line and/or full)
  MaxLines : Integer = 200;


         from within MPL.  It even allows you to define wrap position and
  Forced   : Boolean = False;


         template to completely make it look like its not the Mystic editor!
  Template : String  = 'ansiedit';


         As a little hint the MsgEditSet and MsgEditGet stuff could be used to
  Subject  : String  = 'My subject';


         post process message text on posts.  Like say for example you wanted
  Count    : Integer;


         to write a MPL that allows users to add Tag lines, you could do that
Begin


         by replacing the "Saving message..." prompt and using those two in
  MsgEditSet (1, 'this is line 1');


         order to modify the text before it is saved by Mystic!
  MsgEditSet (2, 'this is line 2!');


         Rather than trying to explain it all, here is an example of all 3:
  Lines := 2;


    Var
  SetPromptInfo(1, 'MsgTo');  // if template uses &1 for "To:" display


      Lines    : Integer = 0;
  If MsgEditor(0, Lines, WrapPos, MaxLines, Forced, Template, Subject) Then Begin


      WrapPos  : Integer = 79;
    WriteLn('User selected to save.');


      MaxLines : Integer = 200;
    WriteLn('There are ' + Int2Str(Lines) + ' of text in buffer:');


      Forced   : Boolean = False;
    For Count := 1 to Lines Do


      Template : String  = 'ansiedit';
      WriteLn(MsgEditGet(Count));


      Subject  : String  = 'My subject';
    Pause;


      Count    : Integer;
  End Else Begin


    Begin
    WriteLn('User aborted the edit.');


      MsgEditSet (1, 'this is line 1');
    Pause;


      MsgEditSet (2, 'this is line 2!');
  End


      Lines := 2;
End


      SetPromptInfo(1, 'MsgTo');  // if template uses &1 for "To:" display
Procedure MENUCMD (CM: String, Data: String)


      If MsgEditor(0, Lines, WrapPos, MaxLines, Forced, Template, Subject) Then Begin
    This procedure will allow menu commands to be ran from within a


        WriteLn('User selected to save.');
    program.  <CM> is the menu command, and <nowiki><DATA> is the menu command</nowiki>


        WriteLn('There are ' + Int2Str(Lines) + ' of text in buffer:');
    data.


        For Count := 1 to Lines Do
    Example:


          WriteLn(MsgEditGet(Count));
    MenuCmd (<nowiki>'NW', ''</nowiki>)


        Pause;
    The above example will run the menu command "NW" with the optional


      End Else Begin
    data field set to nothing.  This example will display the Who's


        WriteLn('User aborted the edit.');
    Online list.  See MYSTIC.DOC for a list of all available menu


        Pause;
    commands.


      End
Function NODENUM : Byte


    End
    This function returns the current node number which the program


  Procedure MENUCMD (CM: String, Data: String)
    is being ran on.


        This procedure will allow menu commands to be ran from within a
    Example:


        program.  <CM> is the menu command, and <nowiki><DATA> is the menu command</nowiki>
    WriteLn ('Welcome to node number ', NodeNum)


        data.
    The above example will print the text "welcome to node number x"


        Example:
    to the screen, where the x will be the current node number which


        MenuCmd (<nowiki>'NW', ''</nowiki>)
    the program is being ran on.


        The above example will run the menu command "NW" with the optional
Variable PROGNAME : String


        data field set to nothing.  This example will display the Who's
    Returns the path and filename of the current MPL program


        Online list.  See MYSTIC.DOC for a list of all available menu
Variable PROGPARAMS : String


        commands.
    Returns any of th eparameters passed to the MPL program as a


   Function NODENUM : Byte
    single string


        This function returns the current node number which the program
Procedure PUTMBASE


        is being ran on.
    This procedure will save the currently loaded MBASE variables into


        Example:
    a message base record.  See the GETMBASE function for a list of


        WriteLn ('Welcome to node number ', NodeNum)
    valid MBASE variables.


        The above example will print the text "welcome to node number x"
    Example:


        to the screen, where the x will be the current node number which
    If GetMBase(1) Then Begin


        the program is being ran on.
         MBaseName := 'Message Base #1'


   
         PutMBase(1)


   Variable PROGNAME : String
    End


        Returns the path and filename of the current MPL program
    The above example will read the data for message base #1, set the


   Variable PROGPARAMS : String
    name to "Message Base #1" and write the data back to the data file.


        Returns any of th eparameters passed to the MPL program as a
Procedure PUTTHISUSER


        single string
    This procedure will save the USER variables into the currently


   Procedure PUTMBASE
    logged in user's record.  See the GETUSER function for a list of


        This procedure will save the currently loaded MBASE variables into
    the USER variables which are saved by the PutThisUser function.


        a message base record.  See the GETMBASE function for a list of
    Example:


        valid MBASE variables.
    GetThisUser


        Example:
    WriteLn ('Welcome ', UserAlias, '.  Your account is being deleted.')


        If GetMBase(1) Then Begin
    UserDeleted := True


             MBaseName := 'Message Base #1'
    PutThisUser


             PutMBase(1)
    HangUp


        End
    The above example will load the USER variables with the currently


        The above example will read the data for message base #1, set the
    logged in user's information, then mark them as deleted with the


        name to "Message Base #1" and write the data back to the data file.
    UserDeleted variable.  Their account is then saved with the


   Procedure PUTTHISUSER
    PutThisUser procedure and then they are hangup on using the HangUp


        This procedure will save the USER variables into the currently
    command.


        logged in user's record.  See the GETUSER function for a list of
Procedure PUTUSER (N: Integer)


        the USER variables which are saved by the PutThisUser function.
    This procedure will save the USER variables into the user file.


        Example:
    The passed N parameter is the record number to save under.  See


        GetThisUser
    the GETUSER function for a list of the USER variables which are


        WriteLn ('Welcome ', UserAlias, '.  Your account is being deleted.')
    saved by the PutUser procedure.


        UserDeleted := True
    Example:


        PutThisUser
    If GetUser(1) Then


        HangUp
    Begin


        The above example will load the USER variables with the currently
         UserDeleted := True


        logged in user's information, then mark them as deleted with the
         PutUser(1)


        UserDeleted variable.  Their account is then saved with the
    End


        PutThisUser procedure and then they are hangup on using the HangUp
    The above example will attempt to load the data from user record


        command.
    1 into the USER variables.  If the data is loaded without any


   Procedure PUTUSER (N: Integer)
    errors, it will mark the user as deleted using the USERDELETED


        This procedure will save the USER variables into the user file.
    variable, and then save the record back to the user file.


        The passed N parameter is the record number to save under.  See
Function READENV (S : String) : String


        the GETUSER function for a list of the USER variables which are
    This function returns the value of the given environment variable


        saved by the PutUser procedure.
    of the operating system.


        Example:
Function REAL2STR(Real,Int):String


        If GetUser(1) Then
    This takes a string and decimal place value.


        Begin
    Ex:


             UserDeleted := True
    Var


             PutUser(1)
      R : Real;


        End
    Begin
 
        The above example will attempt to load the data from user record
 
        1 into the USER variables.  If the data is loaded without any
 
        errors, it will mark the user as deleted using the USERDELETED
 
        variable, and then save the record back to the user file.
 
   Function READENV (S : String) : String
 
        This function returns the value of the given environment variable
 
        of the operating system.
 
   Function REAL2STR(Real,Int):String
 
        This takes a string and decimal place value.
 
        Ex:
 
        Var


          R : Real;
      R := 1234.1234;


        Begin
      WriteLn (Real2Str(R, 2));  // Will print 1234.12


          R := 1234.1234;
   End


          WriteLn (Real2Str(R, 2));  // Will print 1234.12
Procedure SYSOPLOG (S: String)


       End
    This procedure will add a line into the sysop log file found in


   Procedure SYSOPLOG (S: String)
    the logs directory.


        This procedure will add a line into the sysop log file found in
    Example:


        the logs directory.
    SysopLog ('User ran this program.')


        Example:
    The above example will write the text "User ran this program" in


        SysopLog ('User ran this program.')
    the system log file, using the same format as Mystic uses in the


        The above example will write the text "User ran this program" in
    log files (ie, the date and time will automatically be added).


        the system log file, using the same format as Mystic uses in the
Function TIMESTR (DT: LongInt, Mode: Byte)


        log files (ie, the date and time will automatically be added).
    This function converts a packed datetime number into a time


   Function TIMESTR (DT: LongInt, Mode: Byte)
    string.  The passed mode variable defines the format of the time


        This function converts a packed datetime number into a time
    string returned.  Valid options are:


        string.  The passed mode variable defines the format of the time
         0 = 24 hour format: HH:MM:SS


        string returned.  Valid options are:
         1 = 12 hour format: HH:MMa or HH:MMp


             0 = 24 hour format: HH:MM:SS
    Example:


             1 = 12 hour format: HH:MMa or HH:MMp
    WriteLn ('The current time is: ', TimeStr(DateTime, 1))


        Example:
    The above example outputs the current time to the screen using the


        WriteLn ('The current time is: ', TimeStr(DateTime, 1))
    TIMESTR and DATETIME functions.


        The above example outputs the current time to the screen using the
Procedure UPUSER (Sec: Byte)


        TIMESTR and DATETIME functions.
    This procedure will upgrade the currently logged in user's


   Procedure UPUSER (Sec: Byte)
    security level using the validation system.  The passed value


        This procedure will upgrade the currently logged in user's
    is the security level to upgrade to and must be between the


        security level using the validation system.  The passed value
    range of 0 to 255.


        is the security level to upgrade to and must be between the
    Example:
 
        range of 0 to 255.
 
        Example:


        WriteLn ('Upgrading your access to level 20')
    WriteLn ('Upgrading your access to level 20')


        UpUser (20)
    UpUser (20)


        The above example will do a validation upgrade to the security
    The above example will do a validation upgrade to the security


        level of 20.
    level of 20.


<nowiki>-----------------------------------------</nowiki>
<nowiki>-----------------------------------------</nowiki>

Latest revision as of 02:03, 26 February 2019

The Mystic BBS Programming Language Documentation

Copyright (C) 1998-2015 By James Coyle.  All Rights Reserved

All mentioned programs are copyrighted by their respective authors

-----------------------------------------------------------------------

Introduction to Mystic Programming Language (MPL)

-----------------------------------------------------------------------

The Mystic Programming Language (refered to as MPL from here on out) is

not complete.  In the state that it's in now, its still more powerful

than most BBS script languages, but its still not to the point where

it is as powerful as it should be.


The documentation for the MPL is also not complete.  This documentation

as well as the Mystic BBS documentation will be worked on as time

permits and may not be completed for quite some time.  There are some

example programs included with the distribution (found in the scripts

directory) which may help assist you in getting the hang of the MPL

structure and commands.


If you have written any useful MPL programs, please send them via e-mail

to [email protected] so they can be included for download on the

various Mystic BBS support sites.

-----------------------------------------------------------------------

General Notes About Using The MPL

-----------------------------------------------------------------------

The syntax of the Mystic BBS Programming Language follows closely to

that of the Turbo Pascal series of programming compilers.  At one time,

the language was almost 100% Turbo Pascal compatible (except for the

BBS functions) but it has been slightly changed to make it a little

more friendly to the programmer.


Two versions of the programming compiler are available in the scripts

directory.  The first one, MIDE.EXE, is a fully functional IDE for

creating and compiling MPE programs.  This program looks similar to the

Turbo Pascal IDE, including syntax highlighting of all command keywords!

The second version of the compiler is MPLC.EXE.  This is a command line

compiler supplied so you are not forced to use MIDE.EXE to write

programs.  If you do not find the MIDE interface to be satisfactory, then

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

well as some notes about things that aren't working as they probably

should be:


1.  All text after a number sign (#) is considered a comment.  It will    be ignored until the next line of code.  For example:

   WriteLn ('Hello There')  # This is a comment and will be ignored.

2.  Operation types:

   The MPL does not follow the order of operations when doing

   mathmatical equations (ie PEMDAS - parenthesis, exponents,

   multiplication, division, addition, subtraction).  So math    functions are done in the order that they appear in the expression.    This doesn't mean its not POSSIBLE to do PEMDAS-ordered expressions,    it will just take a little more effort on the programmer's behalf.    The following operation codes are supported for mathmatical    equations:

       -   Subtract

       +   Addition

       *   Multiplication

       /   Division

       %   Modulus Operator

2a. Bitwise math:

   MPL fully supports bitwise math and operators!  The following are    implemented:

   AND - Bitwise AND

   OR  - Bitwise OR

   XOR - Bitwise exclusive OR

   SHL - Bitwise shift left

   SHR - Bitwise shift right

   Example:

   Const

   UserDeleted = $04;  // established bit for userdeleted from records.pas

                       // note: this value has changed check records.pas!

   Begin

   GetThisUser

   If UserFlags AND UserDeleted <> 0 Then

    WriteLn('User is deleted');

   End;

3.  Defining variables:  All variables are global to all of the program,

   including procedures.  The syntax for declaring a variable follows:

   Var <VarName> : <VarType>

   Examples:

   var dummy : byte

   var str   : string

   var

     dummy : byte,

     str   : string

   The following variable types are supported:

   Type            Format         Range

   --------------- -------------- -----------------------------------

   Boolean         FALSE/TRUE     0..1

   Char            Text           1 character

   String          Text           Sequence of 1..255 characters

   Byte            Numerical      0..255

   Integer         Numerical      -32767..32767

   Word            Numerical      0..65535

   LongInt         Numerical      -2147483648..214748364

   Real            Numerical      9.99

   All variables exept 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.  The syntax for

   declaring an array variable is:

   Var <VarName> :  ARRAY[<Low>..<High>] of <VarType>

   Var <VarName> :  ARRAY[<L>..<H>, <L>..<H>] of <VarType>

   Var <VarName> :  ARRAY[<L>..<H>, <L>..<H>, <L>..<H>] of <VarType>

   Examples:

   Var Dummy : Array[1..10] of Byte

   Var Str   : Array[5..10] of String

   Var Int   : Array[1..10,1..10,1..10] of Integer

   HEXIDECIMAL values are supported.  They can be used in numeric

   variable assignment numerical evaluation, and in numeric constant

   variables.  A hex value must begin with a $ character.  

   Some examples:

   Const

      MyHexValue = $1F;

   Value := $10;

   If Value = $10 Then WriteLn('Value is 16 <in decimal>');

3b. Record structures: 

Groups data in to records.  This command

   allows you to create a datatype of multiple different variable

   types.

   Defining the record:

   Type

     testrec = record

     x : byte;

     y : byte;

     d : array[1..10,1..5] of string[9]

   end

   Declaring the record:

       Var struct : testrec

   Using the record:

       struct.x:=1

       struct.y:=10

       struct.d[1,1]:='abc123'

   

3c. CODE BLOCKS:  When using multiple lines (more than one line) within a

   IF/ELSE/WHILE/CASE blocks, the lines need to be grouped into

   blocks between BEGIN and END statments.  If there is only one line

   following the IF/ELSE/WHILE/CASE blocks, then no blocking statements

   are needed.

   Examples:

 

   If X = 1 Then

   Begin

      WriteLn('X = '+Int2Str(X))

      X:=X+1

      WriteLn('X = '+Int2Str(X))

   End

   The same is true for the ELSE block.

   If X = 1 Then

   Begin

      WriteLn('X = '+Int2Str(X))

      X:=X+1

      WriteLn('X = '+Int2Str(X))

   End

   Else

   Begin

      WriteLn('X = '+Int2Str(X))

      X:=X-1

      WriteLn('X = '+Int2Str(X))

   End

4.  FOR LOOPS (FOR/FEND):  The syntax for a for loop is as follows:

   For <variable> := <start number> <TO> or <DOWNTO> <end number> Do.  

   For A := 1 to 10 Do

        WriteLn (A)

   For A := 10 DownTo 1 Do

   Begin

        WriteLn (A)

        WriteLn (A)

   End

5.  REPEAT/UNTIL:  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

6.  WHILE:  The syntax for a while loop is as follows:

   While <Boolean Expression> Do

         <Code Here>

   IE:

   While A > 0 and A = 5 Do

       WriteLn ('Blah')

   OR:

   While A > 0 and A = 5 Do

   Begin

       WriteLn ('Blah')

       WriteLn ('More Blah')

   End

7. PROCEDURES: The syntax for defining a procedure is as follows:

  Procedure <Proc Name> (<varname vartype>, <varname vartype>)

    <Code here>

  IE:

  Procedure Hello_World

    WriteLn ('Hello World')

  OR:

  Procedure SomeProc (Str String, A Byte)

    WriteLn ('Str = ' + Str)

    WriteLn ('A   = ' + A)

  End

  OR:

  Procedure SomeProc (Str String)

  Var

    Str2 : String,

    Str3 : String

  Begin             <--- The keyword "BEGIN" is ignored by the compiler           

    WriteLn (Str)        just to maintain a "Pascal-like" feel.

  End

8. IF THEN/ELSE/END:  The syntax of an if/else/end statement:

  If <boolean statement> Then

     <True code here>

  Else If <boolean statement> Then     (optional)

     <True code here>

  Else                            (optional)

     <False code here>

  If Not fEof(fptr) Then

       WriteLn ('We''re not at the end of the file.')

  The above example is the same as the following example, except we've

  added an else statement:

  If fEof(fptr) = False Then

       WriteLn ('We''re not at the end of the file.')

  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...')

8a. CASE statements

   This has actually been expanded on

   from the Pascal standard but still follows the same syntax.  It has been

   expanded to allow CASE of more variable types, such as strings.  See

   the included MPLTEST.MPS for examples.

   Var I : Integer = 10

   Case I Of

      1 : WriteLn('I = 1')

      2 : Begin

            I:=I+1

            WriteLn('I = 3')

          End

      2,3,4,5,6,7,8,9: WriteLn('Not 1, 2, or 10')

   End

   Var S : String = 'ABCDEFG'

   Case S[3] Of

      'A': WriteLn('S[3] = '+S[3])

      'B','C','D': WriteLn('S[3] = '+S[3])

   Else

      WriteLn('This is the default choice')

   End

9.  The USES command must be declared before ANY other variables

   or your program may not function properly.  See documentation for

   the USES command for further information.

10. FUNCTIONS: The syntax for defining a function is as follows:

   Function <Function Name> (<varname vartype>) : <result type>

   IE:

   Function AddTen (Num Byte) : Byte

   Begin

     AddTen := Num + 10

   End

11. 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.  If you are assigning a value to a variable,

   constant values will not be recongnized.

-----------------------------------------------------------------------

General Functions and Procedures

-----------------------------------------------------------------------

Function ABS (Num: LongInt) : LongInt

   This function takes a signed integer and returns the absolute value.

   Example:

   Var Int : LongInt = -1234

   WriteLn('The absolute value of '+Int2str(Int) +' is '+Abs(Int)+'.')

Function ALLOWARROW (Boolean)

   

   Used to turn on arrow key processing in the READKEY function.  It is

   also used outside of MPL so use with caution.

   Example:

   AllowArrow := True

   ReadKey

Variable ALLOWMCI (boolean)

   This function toggles on/off MCI code parsing.  This is used outside of

   MPL so adjust this with caution.

Procedure APPENDTEXT (FileName, Text: String).  

   This procedure will append a single line of text onto a text file.  If

   the file does not exist, it will be created.  Example:

Function BITCHECK (B : Byte; I : Integer) : Boolean

   This function accepts a bit position and checks it against an integer,

   returning true or false if the bit is on.  So for example in the

   Records, the third bit in UserFlags is UserDeleted:

   GetThisUser

   If BitCheck(3, UserFlags) Then WriteLn('User is marked deleted');

Procedure  BITSET (B : Byte; I : Integer)

   This procedure accepts a bit position and an integer and sets the

   bit ON/OFF based on a boolean:

   GetThisUser

   BitSet(3, UserFlags, True);  // user is marked as deleted

Procedure BITTOGGLE (B : Byte; I : Integer)

   This procedure accepts a bit position and an integer and toggles the

   bit.

   GetThisUser

   BitToggle(3, UserFlags);  // undeletes if they are deleted or deletes if

                             // they are not deleted.

Variables CFGCHATSTART CFGCHATEND.  

   These return the byte of the chat hour start and end variables from the

   System Configuration

Procedure CLRSCR

    This function will clear the screen.

    Example:

    CLRSCR

    Writeln ('The screen was just cleared.')

    The above function will clear the screen and write the text "The

    screen was just cleared." to the screen.

Function DATE2DOS (Str : String) : LongInt

    This function takes a MM/DD/YY format date and converts it to

    DOS packed datetime format.

    Var DStr : String = '01/01/14'

    Var PDt  : LongInt

    PDt := Date2Dos(DStr)

Function DATE2JULIAN (Str : String) : LongInt

    This function takes a MM/DD/YY format date and converts it to a

    Julian date format.

Function DATEG2J (Str : String) : LongInt

    This function takes a gregorian date format (MMDDYY) and converts

    it to a Julian format

Function DATEJ2G (LI : LongInt) : String

    This function takes a julian date format and converts it to a

    gregorian format (MMDDYY).

Function DATEJULIAN : LongInt

    This function returns the Julian value of the current date.

Function DATESTRJULIAN (JD : LongInt) : String

    This function returns the MM/DD/YY string value of the julian date.

Function DATEVALID (Str : String) : Boolean

    This function takes a MM/DD/YY date and returns true or false

    depending on if the date is valid (ie, month is 01-12, etc).

Function DAYOFTHEWEEK

    Returns a number between 0-6 depending on the day of the week:

    0 = Sun, 1 = Mon, 2 = Tue, 3 = Wed, 4 = Thu, 5 = Fri, 6 = Sat

Function DAYSAGO (JD : LongInt) : Integer

    This function takes the Julian date value and returns the number

    of days between the current date and the passed date.

Function DAYOFWEEK : Integer

    This function will return a number between 0-6 depending on the

    day of the week:

    0 = Sun, 1 = Mon, 2 = Tue, 3 = Wed, 4 = Thu, 5 = Fri, 6 = Sat

Procedure DELAY (MS: Word)

    This procedure will delay for a specified number of milliseconds.

    Example:

    DELAY (1000)

    The above example will delay the program for one second.

Function DOSERROR : Byte

    This function returns the current DosError and is used with the

    FindFirst and FindNext functions.  The possible values which may

    be returned by DosError are as follows:

    Value  Meaning

    -----  ---------------------

      0    No error

      2    File not found

      3    Path not found

      5    Access denied

      6    Invalid handle

      8    Not enough memory

     10    Invalid environment

     11    Invalid format

     18    No more files

    -----  ---------------------

    Example:

    FindFirst ('*.*', AnyFile)

    While DosError = 0 Do Begin

         WriteLn ('File Name: ', DirName)

         FindNext

    End

    FindClose                

    The above example will list all files in the current directory.

    The DosError function is used to return when there are no more

    files to be listed.  For more information on this see the reference

    for the FindFirst and FindNext functions.

Procedure FINDCLOSE

    This function is used along with the FindFirst and FindNext

    functions.  It is called only after all "Find" procedures have

    completed.  See the "FindFirst" and "FindNext" command references

    for more information.

Procedure FINDFIRST (Mask : String, Attributes)

    This function is used to search a drive for files using a supplied

    file mask and attribute list.  The results of the search are held

    in the DIR variables as listed below.

    Mask : The mask variable must contain at least a file mask

           (ie "*.*") but can also contain a drive and directory name

           as well (ie "C:\MYSTIC\TEXT\*.*").

    Attributes : The file attributes are used to specify what type of

                 files to return in the DIR variables.  The following

                 is a list of supported file attributes:

                 Dec Description Returns

                 --- ----------- -----------------

                 001 ReadOnly    files marked as "read only".

                 002 Hidden      files marked as "hidden".

                 004 SysFile     files marked as "system files".

                 008 VolumeID    files marked as "volume ID".

                 016 Directory   files marked as "directory".

                 032 Archive     files marked as "archive".

                 066 AnyFile     any and all files.

                 These attributes can be combined when passed to

                 FindFirst.  For example: 1 + 2 will return

                 any files which have been marked as "readonly" OR

                 "hidden".  Example: 16 (DIRECTORY) will only return names

                 of directories.

    DIR Variables : The DIR variables are what contain the information

                    returned by the FindFirst command.  If your program

                    is going to use these variables, it must be declared

                    with the USES statement at the beginning of your

                    program source code.  The following DIR variables

                    are supported:

                    DirName : Holds the file name.

                    DirSize : Holds the file size.

                    DirAttr : Holds the file attributes

                    DirTime : Holds the file date and time in packed

                              date format.  The DateSTR and TimeSTR

                              functions will need to be used in order

                              to display these.

    Example:

    USES DIR

    WriteLn ('The following files are in the C:\ directory:')

    WriteLn ('')

    FindFirst ('C:\*.*', 66)

    While DosError = 0 Do

    Begin

         WriteLn ('File Name: ', DirName)

         WriteLn ('     Size: ', DirSize)

         WriteLn ('     Date: ', DateSTR(DirTime), 0)

         WriteLn ('     Time: ', TimeSTR(DirTime), 1)

         Write   ('Press a key to search for more.~PN')

         FindNext

    End

    FindClose

    WriteLn ('No more files have been found.')

    The above example will list all files which fit the file mask of

    "C:\*.*" and fit the attributes of either ReadOnly or Archive.

    The DOSERROR function is used to determine when there are no more

    files found (See the DOSERROR reference).  If a file has been

    found, it will then be printed to the screen using the DIR

    variables.  The FindNext functon is used to find the next file

    that matches the name and attributes specified in the earlier call

    to FindFirst.  FindClose is used when all "Find" functions have been

    completed.

Procedure FINDNEXT

    This procedure is used to find the next file which matches the file

    mask and attibutes specified in the last call to FindFirst.

    Example:

    Uses DIR

    FindFirst ('*.*', 32)

    While DosError = 0 Do

    Begin

         WriteLn ('File Name: ', DirName)

         FindNext

    End

    FindClose

    The above example uses the FindFirst/FindNext functions to do a

    listing of all files in the current directory.  The DosError

    function is used to determine when no more files have been found.

Procedure GOTOXY (X: Byte, Y: Byte)

    This procedure will move the cursor to a specified X and Y

    position on the screen.  This only works for users who have ANSI

    graphics.

    Example:

    CLRSCR

    GotoXY (1, 10)

    WriteLn ('Hello')

    The above example will clear the screen then goto the first column

    of the tenth line and output the text "Hello" to the screen.

Procedure HALT

    This procedure will exit the program and return the user back to

    the BBS immediately.

    Example:

    If Graphics = 0 Do

    Begin

         WriteLn ('Sorry, you do not have ANSI graphics.')

         Halt

    End

    The above example will check to see if the user has ANSI graphics

    and if not, display "Sorry, you do not have ANSI" and exit the

    program immediately by using the HALT command.

Function INITIALS (String) : String

    This function takes a user name and attempts to return one or two

    character initials.

    S := Initials('Jack Phlash'); // should return "JP"

Function INPUT (Field: Byte, Max: Byte, Mode: Byte, Default: String) : String

    This function gives input to the user, and returns the result of

    the input as a string variable.

    The Field parameter is the size of the input field (in characters)

    that the user will be able to see.  If the field size is smaller

    than the maximum number of characters allowed in the input, the

    input line will scroll when the user reaches the end.  This field

    is usually set to the same as the Max parameter.

    The Max parameter is the maximum number of characters that

    Input will allow to be entered.  Note that the Field parameter, in

    most cases, should be set to the same value as this.

    The Mode parameter is the type of input that will be accepted, and

    can be any one of the following input types:

         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 +-

    NOTE: If any of the above input values are increased by 10, Input

    will create an input field using the foreground/background color

    that has been defined for that language.  For example, input type

    11 will function the same as input type 1, but will fill an input

    field to the maximum field length.

    The Default parameter can be used to force a default text into

    the input field.  If you do not wish to have any default text in

    the buffer, supply a blank string parameter (ie '').

    EXAMPLE:

    Var Str : String

    Write ('Enter something: ')

    Str := Input (30, 30, 1, '')

    The above example will print the text "Enter something: " to the

    screen and the allow input of up to 30 characters in length, using

    input type 1 (allows all characters).  No default text has been

    supplied so the input field will be empty by default.

    Var Str : String

    Write ('Enter something: ')

    Str := Input (30, 30, 11, 'Default')

    The above example will function just like the first example, except

    it will create an input field background and stuff the text of

    "Default" into the input field.

Function INPUTNY (Text: String) : Boolean

    This function prompts the user with a Yes/No question, defaulting

    to No. TRUE will be returned if the user answered Yes, or FALSE if

    the user answered No.  The passed Text variable is the text that is

    displayed to the user asking the question.

    Example:

    If Not InputNY('Do you want to run this program? ') Then

         Halt

    The above example will prompt the user with the Yes/No question

    passed as <Text>.  This question will default to No.  If the user

    answers No, the program will halt from being executed.

Function INPUTYN (Text: String) : Boolean

    This function prompts the user with a Yes/No question, defaulting

    to Yes.  TRUE will be returned if the user answered Yes, or FALSE

    if the user answered No.  The passed Text variable is the text

    that is displayed to the user asking the question.

    Example:

    If Not InputYN('Do you want to run this program? ') Then

         Halt

    The above example will prompt the user with a Yes/No question,

    asking "Do you want to run this program?".  If the user responds

    No, the program will not run, using the Halt command.

Function ISARROW : Boolean

    This function is used along with the READKEY function.  After

    READKEY is called, this function can be checked to process various

    extended keys, such as arrow keys.  When ISARROW is true, READKEY

    will return the following:

    ASCII #     Char     Key Pressed

    -------     ----     -----------

    71          G        Home

    72          H        Up Arrow

    73          I        Page Up

    75          K        Left Arrow

    77          M        Right Arrow

    79          O        End

    80          P        Down Arrow

    81          Q        Page Down

    83          S        Delete

    The character returned by READKEY can be checked by either the

    ASCII # or the actual character.  Below is an example:

    Example:

    Var Ch : Char

    Ch := ReadKey                 # Input one key

    If IsArrow Then               # Is key returned an arrow key?

      If Ch = 'H' Then

        WriteLn ('Up arrow')

      Else If Ch = Chr(80) Then

        WriteLn ('Down arrow')

    Else                          # No arrow key.  A normal character

      WriteLn ('You entered character: ', Ch)

    The above example reads a key with READKEY and then uses the

    ISARROW function to process the Up Arrow and Down Arrow keys.

Function ISUSER (String) : Boolean

    This function takes a string value which can contain either a user

    realname, handle, or user perm index number.  If the user exists,

    it will return a TRUE result or FALSE if the user does not exist.

Function KEYPRESSED : Boolean

    This function returns TRUE if a key has been pressed either

    remotely or locally.  Keep in mind two things about this

    function:

         (1) It doesn't check for inactivity timeout.  If you are

             using this function to wait for a key to be pressed then

             you may want to use the TIMER function and check for

             inactivity.

         (2) This function only returns whether a key was PRESSED.

             It does not actually read the key out of the buffer.

             See the READKEY function for reading keys from the

             buffer.

    Example:

    Repeat

    Until KeyPressed

    WriteLn ('You pressed a key!')

    The above example will wait for a key to be pressed and then

    write to the screen "You pressed a key!".

  Function MCI2STR (String) : String

    This function will take the value of the supplied 2-character MCI

    code (without pipe) and returns the string value of that code.

    Ex:

    Var BBSName : String

    

    BBSName:=MCI2Str('BN')

    WriteLn('The name of this BBS is "'+BBSName+'"')

  Function MCILENGTH (String) : Integer

    This function works just like LENGTH except it tries to ignore MCI

    codes.  It doesn't check for actual validity of MCI codes.

    Var B : Byte;

    B := MCILength('|15Hello|UH');

    WriteLn ('Length should be 5: ' + Int2Str(B));

  Function MOREPROMPT : Char

    This function displays the system more prompt and returns a Char

    value of either Y N or C depending on what the user selected.

    Var C : Char

    C:=MorePrompt

Procedure MOVEX (Pos : Byte)

        This procedure is used to move the cursor to the passed X coordinate

        on the screen.  It only works if the user has ANSI graphics enabled.

        Example:

        MoveX (20)

        WriteLn ('This text starts on the 20th space')

Procedure MOVEY (Pos : Byte)

        This procedure is used to move the cursor to the passed Y coordinate

        on the screen.  It only works if the user has ANSI graphics enabled.

        Example:

        MoveY (10)

        WriteLn ('This is on the 10th line of the screen')

Function PARAMCOUNT : Byte

    This function is used to determine the number of command line

    options which have been passed to the MPE program.  For more

    information, see the PARAMSTR function.

    Example:

    If ParamCount < 2 Then Begin

         WriteLn ('Invalid command line.')

         Halt

    End

    The above example will check to see if less than 2 command line

    options have been passed to the MPE program.  If there are less

    than two, the program will terminal with a "invalid command line"

    message.

Function PARAMSTR (Number : Byte) : String

    This function returns the command line option specified by the

    NUMBER parameter.  A command line is the optional data which

    is passed on the "Data" field of a menu command.  For example,

    when defining a menu command which executes an MPE program in

    the menu editor, the text after the program name becomes command

    line options.

    Menu Command: GX

    Data        : BULLETIN p1 p2 p3 p4

    If the above was defined in the menu editor, the following would

    be true:

    ParamCount  would return 4

    ParanStr(0) would return "BULLETIN"

    ParamStr(1) would return "p1"

    ParamStr(2) would return "p2"

    ParamStr(3) would return "p3"

    ParamStr(4) would return "p4"

    Note that ParamStr(0) will ALWAYS return the file name of the

    MPE program being executed.  Even when there are no other

    parameters defined.

Procedure PAUSE

    Envokes the Mystic pause prompt as defined in the current

    language file.

Function PAUSEPOS : Byte

 

    This function gives access to Mystic's internal line

    counter used for screen pauses.

Function RANDOM (Max: Word) : Word

    This function will return a random number within the range

    specified.

    Example:

    Var A : Byte

    A := Random(255)

    WriteLn (A)

    The above example will generate a random number within the range

    of 0 to 255 in the variable A and then print it to the screen.

Function READKEY : Char

    This function will read a key from the buffer and return it as

    a char variable.  If there are no keys in the buffer, readkey will

    wait for a key to be pressed.

    Example:

    Var Ch : Char

    Repeat Until KeyPressed

    Ch := ReadKey

    WriteLn ('You entered: ', Ch)

    The above example will wait for a key to be pressed by using the

    KEYPRESSED function.  Afterwards, the key will be read into the

    CH variable using readkey, and then print it to the screen.

Procedure SETPROMPTINFO (N : Integer; S : String)

   This allows you to set Mystic's internal "changing" PromptInfo MCI

   codes (the |&X codes).  For example:

   SetPromptInfo(1, 'Hello!');

   WriteLn ('This MCI code would like to say: |&1');

   As a side note, there is NOT a GetPromptInfo because you can simply use

   MCI2STR:

   WriteLn('This MCI code would like to say: ' + Mci2Str('&1'));

Procedure STUFFKEY (S : String)

    This function will stuff a string of text into the keyboard

    buffer.  This can be used to force your program into thinking

    the user had actually typed <S>.

    Example:

    Var Ch : Char

    StuffKey ('A')

    Ch := ReadKey

    WriteLn ('You entered: ', Ch)

    The above example will stuff the character "A" into the input

    buffer, where it will be read into Ch using the ReadKey function.

    It is possible to stuff entire strings of text into the buffer

    too.

    Example:

    Var Str : String

    StuffKey 'Hello World'

    Str := Input (20, 20, 1, '')

    The above example will stuff "Hello World" into the input buffer.

    This will cause the input function to think the user has actually

    typed in "Hello World".  In this case, the above is the same as

    supplying "Hello World" in the <DEFAULT> field of the Input

    function.

Function TIMER : LongInt

    This function will return the current number of seconds which have

    passed since midnight.  This function can be used to time how long

    a user is doing something.

    Example:

    Var StartTime : LongInt

    Var EndTime   : LongInt

    Var Total     : LongInt

    Var Str       : String

    StartTime := Timer

    Write ('Enter something: ')

    Str := Input (40, 11, 'Nothing')

    EndTime := Timer

    Total := EndTime - StartTime

    WriteLn ('You took ', Total, ' seconds to type something!')

    The above example will prompt the user to type something and time

    how long in seconds they took.  WriteLn will then display the

    number of seconds the user took to the screen.

Function TIMERMIN : LongInt

    This function works just like TIMER except returns minues

    instead of seconds.

Function WHEREX : Byte

    This function returns the current X coordinate of the cursor.

    Example:

    Var X : Byte

    Var Y : Byte

    X := WhereX

    Y := WhereY

    WriteLn ('      World')

    GotoXY  (X, Y)

    WriteLn ('Hello')

    The above example will save the current X and Y cursor positions

    and then write the text "World" to the screen.  After which, it

    will return to the saved X and Y position and write the text

    "Hello" to the screen.  The end result will be the text of

    "Hello World" written to the screen.  Note: GotoXY can only be

    used if the user has ANSI graphics mode.

Function WHEREY : Byte

    This function returns the current Y coordinate of the cursor.

    For more information on this function, please see the definition

    of the WHEREX function.

Procedure WRITE (Text)

    This procedure is used to write text to the screen without

    going to the next line (ie, without sending a carriage return).

    All text to be printed to the screen should be enclosed inside of

    ' characters.  If you wish to print the value of a variable to

    the screen, just include the variable name without the '

    characters.  If you wish to combine multiple text and variables,

    they must be separated by commas.

    Examples:

    Write ('Hello ')

    Write ('World')

    This example will write the text "Hello World" to the screen.

    Write ('Hello World')

    This example does the exact same thing as the function above, but

    makes a little more sense.

    Var Str : String

    Str := 'Hello World'

    Write (Str)

    This example will write the value held in the variable Str to the

    screen.  The resulting output will be "Hello World"

    Var Str : String

    Str := 'Hello '

    Write (Str, 'World')

    This example will write the value of the variable Str to the

    screen, followed by the text "World".  The resulting output will

    be "Hello World".  An unlimited number of variables and text can

    be outputted with the Write statement, but they must all be

    separated by a comma, as shown above.

    If a ' character needs to be printed to the screen, it can be done

    by doubling the ' character.  For example:

    Write ('This is how it''s done.')

    The resulting screen output will be "This is how it's done", with

    only one ' character.

    All MCI display codes can be used within the Write statement.  If

    you wish to change the display colors, use the MCI color system to

    do so.  For example:

    Write ('~14Hello World')

    This example will write the text Hello World in yellow to the

    screen.  All MCI display codes are available to the write

    statement.

Procedure WRITELN (Text)

    This procedure outputs text to the screen.  It functioning is

    identical to the WRITE statement except that it goes to the next

    line after the text is printed (ie, it sends a carriage return).

    For example:

    WriteLn ('Hello')

    WriteLn ('World')

    The above example will write the text "Hello" on one line, and

    then the text of "World" on the next line.

Procedure WRITEPIPE (Text)

    This function works just like WRITE but only parses pipe color

    codes instead of all MCI codes.

Procedure WRITEPIPELN (Text)

    This procedure works just like WRITEPIPE but with a CRLF at the end.

Procedure WRITERAW (Text)

    This procedure works just like WRITE except it does not parse

    any pipe color codes OR MCI codes.

Procedure WRITERAWLN (Text)

    This procedure is the same as WRITERAW, but with a CRLF at the end.

Procedure WRITEXY (X,Y,Z: Byte; Str : String)

    This procedure writes a string of text at the defined X/Y location with a

    specific text color attribute 'Z'.  This of course requires the user has

    ANSI to function properly.  This function will NOT parse MCI pipe codes.

    Example:

    WriteXY (1, 10, 8, 'Prints at X:1 Y:10 with dark grey text');

Procedure WRITEXYPIPE (X,Y,Z: Byte; Len: Integer; Str : String)

    This procedure writes a string of text at the defined X/Y location with a

    specific text color attribute 'Z'.  This of course requires the user has

    ANSI to function properly.  This function will NOT parse MCI pipe codes.

    Example:

    WriteXYPipe (1, 10, 8, 50, 'This pads to 50 chars at location 1,10');

-----------------------------------------------------------------------

String Handling Functions and Procedures

-----------------------------------------------------------------------

Function ADDSLASH(S: String) : String

   takes a directory and appends the appropriate ending backslash or

   forward slash depending on operating system.  If the slash is already

   there, it does nothing.

Function CHR (B: Byte) : Char

    This function will take a numerical byte value and return it's

    ASCII character.  The byte value must be between 0 and 255 as

    there are only 255 characters in the ASCII character set.

    Example:

    WriteLn ('Hello', Chr(32), 'World')

    This will output the text "Hello World" to the screen.  The ASCII

    number for the space character is 32 and by passing a 32 to CHR,

    a space is returned.

Function COPY (S: String, Index: Byte, Count: Byte) : String;

    This function will copy a defined part of a string and return

    the copied portion as a string.

    Example:

    Var Str : String

    Str := 'Hello World'

    WriteLn (Copy(Str, 1, 5))

    This will output "Hello" to the screen.  The copy function takes

    the given Str and copies Count number of character from the Index.

    So the above copies 5 characters starting at the 1st character in

    Str and WriteLn outputs it to the screen.

Procedure DELETE (S: String, Index: Byte, Count: Byte)

    This procedure will delete a defined portion of a string

    variable.

    Example:

    Var Str : String

    Str := 'Hello World'

    Delete (Str, 6, 6);

    WriteLn (Str)

    This example will delete 6 characters from the string Str starting

    at the 6th character.  The resulting output from WriteLn will be

    "Hello"

Function FillChar (V: Variable; S: LongInt; C Char ): String

    Fills variable V with Char C for S size.

    type

      myuserrecord = record

      username  : string[30];

      somevalue : array[1..5] of byte;

    end;

    var

      u : myuserrecord;

    begin

      fillchar(u, sizeof(u), #0);

    end.

Procedure INSERT (Source: String, Target: String, Index: Byte)

    This procedure will insert text into a string at a specified

    location.

    Example:

    Var Str : String

    Str := 'Mystic v1.00'

    Insert ('BBS ', Str, 8)

    WriteLn (Str)

    The above example will insert the text "BBS" into the Str variable

    starting at the 8th character in the string.  The result WriteLn

    output would be "Mystic BBS v1.00"

Function INT2STR (L: LongInt) : String

    This function converts a numerical type variable to a string

    type variable.

    Example:

    Var A : Byte

    Var S : String

    A := 255

    S := Int2Str(A)

    WriteLn (S)

    The above example sets the numerical variable to the value of

    255, which is then converted to a string variable using Int2Str.

    The resulting value of S will be '255' as WriteLn will output to

    the screen.

Function LENGTH (S: String) : Byte

    This function returns the length in characters of the passed

    string variable.

    Example:

    WriteLn (Length('Hello World'))

    The above example would output "11" to the screen, which is the

    number of characters in the text passed to Length.

Function LOWER (S: String) : String

    This function converts a passed string variable to all lower

    case letters.

    Example:

    WriteLn (Lower('HELLO'))

    The above statement would output the text "hello" to the screen.

    The original text of HELLO is converted to all lower case letters

    and than displayed by WriteLn.

Function ONEKEY (Keys : String; Echo : Boolean) : Char

    This function accepts a string of uppercase letters, and wait for

    input from the user.  If the keystroke is among the characters in

    Keys, it will return that character.  If the keystroke is not among

    the Keys string, it will do nothing.  If Echo is set to TRUE, it

    will also echo the Key to the screen.

    Var Ch   : Char

    Var Keys : String = 'ABCDQ'

    Ch := OneKey(Keys,True)

    WriteLn('You selected '+Ch+'.')

Function ONEKEYRANGE (String, Int, Int ) : Char

    This function works similar to OneKey, except that it will also allow

    for a number input within a certain range.  The number value is

    stored in a variable called RangeValue and the function returns a #0

    if a number was entered.  For example:

    Var

      Ch : Char;

    Begin

      Write ('Enter letters A-G or a number between 1-50: ');

      Ch := OneKeyRange('ABCDEFG', 1, 50);

      If Ch = #0 Then

        WriteLn ('You entered a number: ' + Int2Str(RangeValue))

      Else

        WriteLn ('You entered character: ' + Ch);

    End.

Function ORD (C: Char) : Byte

    This function returns the ASCII code of the passed Char variable.

    This function works the exact opposite of the CHR function.

    Example:

    WriteLn (Ord(' '))

    The above example would output the text "32" to the screen because

    32 is the ASCII character code for space.

Function PADCT (S: String, N: Byte, C: Char) : String

    This function pads a string to the center with the specified

    character.

    Example:

    Var Str : String

    Str := PadCT('Hello World', 80, ' ')

    WriteLn (Str)

    The above example would display the text "Hello World" centered on

    the screen.  The PadCT function returns the text "Hello World"

    centered in 80 spaces with the character of " " used to fill the

    blank spaces.

Function PADLT (S: String, N: Byte, C: Char) : String

    This function returns a text string padded with spaces to the

    left side.

    Example:

    Var Str : String

    Str := PadLT('Hello World', 79, ' ')

    The above example would return a string which is 79 characters in

    length with the text "Hello World" as the leftmost part of the

    string.  The passed character is the character that is used to

    fill the blank spaces.

Function PADRT (S: String, N: Byte, C: Char) : String

    This function returns a text string padded with spaces to the

    right side.

    Example:

    Var Str : String

    Str := PadRT('Hello World', 79, ' ')

    The above example would return a string which is 79 characters in

    length with the text "Hello World" being the rightmost part of the

    string.  The empty spaces are filled with the passed charcter (in

    this case ' ').

Function POS (Sub: String, S: String) : Byte

    This function returns the starting position of a substring in a

    string.

    Example:

    Var A : Byte

    A := POS('World', 'Hello World')

    WriteLn (A)

    The above example would output "7" to the screen becase POS

    returns the position of the text "World" in the string

    "Hello World".  If POS does not find a match, a zero will be

    returned.  IE: A := POS('Blah', 'Hello World') would return a zero

    because the text "Blah" was not found in the string "Hello World".

Function REPLACE(Str1, Str2, Str3 : String) : String

    This function replaces all occurances of a supplied text and

    returns a string.  Ex:

    Var Str : String = 'Hello Hello Hello';

    Str := Replace(Str, 'Hello', 'World');  // Str is now World World World

Function STRCOMMA(LI : LongInt) : String

    This function  accepts a longint and returns it as a string, with

    commas added where applicable:

    Ex:

    WriteLn (strComma(1000000));  // will print 1,000,000

Function STR2INT (S: String) : LongInt

    This function converts a passed string variable to a numerical

    variable.  The passed string variable must contain a valid number.

    Example:

    Var A : Byte

    Var S : String

    S := '100'

    A := Str2Int(S)

    WriteLn (S)

    WriteLn (A)

    The above example will output "100" twice the screen.  The

    variable S is assigned to '100' and the function Str2Int converts

    the string into a numerical value which is assigned to variable

    A.

Function STRIPB (S1, S2 : String) : String

    This function strips both sides of the string if a specific character.

    Var S : String = '     Hello     ';

    S := StripB(S, ' ');

Function STRIPL (S1, S2 : String) : String

    This function strips the left side of a string of any specified

    leading characters.

    Var S : String = '    Hello';

    S := StripL(S, ' ');

Function STRIPR (S1, S2 : String) : String

    This function strips the right side of a string of any specifcied

    trailing character:

    Var S : String = 'Hello     ';

    S := StripR(S, ' ');

Function STRIPLOW (String) : String

    This function strips all chracters from a string that are less than

    ascii code #32.

    Var S : String = #12#12#12#12 + 'Hello';

    S := StripLow(S);

Function STRIPMCI (S : String) : String

    This function will strip the passed string variable of all MCI

    codes and return the "cleaned" version.

    Example

    Var S : String

    S := '|10|H|02ello |10W|02orld|07'

    WriteLn ('Normal   : ', S)

    WriteLn ('Stripped : ', StripMCI(S))

    The above example assigns a string with MCI codes in it to the S

    variable.  It then writes the original string and the stripped

    string to the screen, so the difference is shown.

Function STRIPPIPE (String) : String

    This function takes a string and strips only pipe color codes

    from it.

    S := StripPipe('|15Hello there, |UH');  //returns "Hello There, |UH"

Function STRMCI (String) : String

    This function takes an entire string and attempts to translate any

    MCI codes found in it, returning the entire result.

    S := StrMci('Hello |UH');

Function STRREP (Ch: Char, Num: Byte) : String

    This function returns a string filled with character <CH> to the

    length of <NUM>.

    Example:

    WriteLn (strRep('-', 60 ))

    The above example will use strRep to create a string 60 characters

    long of the character '-', then write it to the screen.  So the

    outputted text would look like:

    "------------------------------------------------------------"

Function STRWRAP(Str, Str2 : String; Len: Integer) : Byte

    This function takes two strings and wraps them after the word closest

    to the maximum supplied length.  It optionally returns the actual

    position where it wrapped.

    Var Str   : String = 'This will wrap';

    Var Str2  : String = '';

    Var Where : Byte;

    Where := strWrap(Str, Str2, 10);

    WriteLn ('It wrapped at ' + Int2Str(Where));

    WriteLn ('First string: ' + Str);

    WriteLn ('Second string: ' + Str2);

Function UPPER (S: String) : String

    This function coverts the passed string variable to all upper

    case letters.

    Example:

    WriteLn (Upper('hello'))

    The above example would output the text "HELLO" to the screen.

    The UPPER function converts the passed text of "hello" to all

    upper cased letters, which is then printed to the screen by

    WriteLn.

Function WORDCOUNT (S,C: String) : Integer

    Function WordCount returns the number of words in a string using

    the final parameter to define the character that determines what

    separates words.  Ex:

    Str := 'Hello this is a test';

    WriteLn ('Str has ' + Int2Str(WordCount(Str, ' ')) + ' words in it.');

Function WORDGET(I : Integer, S, C : String) : String

    returns the actual word at a specific word count.

    S is the inputted string value.

    I is the numerical value of the position where the word can be found.

    C is the string value used as the word separater.

    Ex:

    Str := 'Hello this is a test';

    WriteLn('The second word was: ' + WordGet(2, Str, ' '));

Function WordPos (I : Integer; S, C : String ) : Integer

    Function WordPos returns the character position in the string where

    specific word is located.

    S = Inputted string value

    I = Index value of the the desired word within S

    C = String value of the word separater.

    Ex:

    Str := 'Hello this is a test';

    WriteLn ('Second word is at: ' + Int2Str(WordPos(2, Str, ' ')));

    See Also : WordCount, WordGet

-----------------------------------------------------------------------

File Accessing Functions and Procedures

-----------------------------------------------------------------------

Function FEOF (Handle) : Boolean

    This function will return true if the file position of an opened

    file is at the End Of the File (EOF).  The passed Handle value is

    the file number of the already opened file.

    Example:

    Var Str : String

    Var Fpt : File

    FOpen (1, Text, Reset, 'BLAH.TXT')

    While Not Eof(1)

         FReadLn (1, Str)

         WriteLn (Str)

    End

    FClose (1)

    The above example will open a text file under the filename of

    BLAH.TXT.  The WHILE loop is used to repeat the code until the

    EOF (end of file) is reached.  The FCLOSE statement will close

    the file after it is done being accessed.

    The result of the above example will be (in pseudocode):

    1. Open text file.

    2. If not at the end of file, run this code:

        3. Read line from text file into string variable

        4. Print line read from text file to the screen.

        5. Goto 2.

    6. Close the text file.

    So the above example will basically write the entire text file to

    the screen.

Procedure FCLOSE (File)

    This procedure closes an already opened file.  The passed Handle

    value is the file number of the opened file.  All files which

    are opened MUST be closed after they are not being accessed any

    more.

    For example:

    Var Fptr : File

    fAssign  (Fptr, 'BLAH.TXT', 66)

    fReWrite (Fptr)

    <Code to access file goes here>

    fClose (Fptr)

    The above example opens a file using the FOPEN procedure.  When

    the file has been opened successfully, it can be accessed in

    various ways using the file I/O functions.  Afterwards, it MUST

    be closed using the FCLOSE procedure as shown above.

Function FILECOPY (Source: String, Dest: String) : Boolean

    This function will copy a file from the specified source location

    to the specified destination location.  The function will return

    as TRUE if the file was copied successfully, or FALSE if an error

    occured.  Note:  The file which is being copied should not already

    be opened for File I/O by the program.

    Example:

    Write ('Copying C:\HELLO.TXT -> D:\HELLO.TXT: ')

    If fileCopy ('C:\HELLO.TXT', 'D:\HELLO.TXT')

         WriteLn ('OK')

    Else

         WriteLn ('ERROR')

    End

    The above example will attempt to copy the file "C:\HELLO.TXT" to

    the destination of "D:\HELLO.TXT".  If the file is copied without

    any problems an "OK" will be printed to the screen.  If an error

    occured while copying, "ERROR" will be printed to the screen.

Procedure FILEERASE (FileName: String)

    This procedure is used to erase an existing file from the disk.

    The FileName variable is a string variable which contains the

    file name which is to be erased.  The result of the FILEERASE

    procedure can be checked by checking the DOSERROR function.

    DOSERROR will return a 0 if successful or a 2 if an error occured.

    Example:

    FileErase ('C:\HELLO.TXT')

    The above example will erase the file "C:\HELLO.TXT" if it exists.

Function FILEEXIST (FileName: String) : Boolean

    The above function will check to see if a file exists, and return

    TRUE if it does.  The passed FileName string if the path and file

    name of the file to check.  This file should not already be opened

    with the FOPEN procedure.

    Example:

    If FileExist('BLAH.TXT') Then

         WriteLn ('BLAH.TXT exists.')

    Else

         WriteLn ('BLAH.TXT does NOT exist.')

    The above example will check to see if the file "BLAH.TXT" exists

    and if it does, will output "BLAH.TXT exists" to the screen.  If

    BLAH.TXT does NOT exist, the output will be "BLAH.TXT does NOT

    exist".

Function FPOS (File) : LongInt

    This function returns the current file position of an opened

    file.  The passed Handle is the file handle number used when the

    file was opened.  The FilePos function only works for files that

    are opened as Binary, since Text files are read line by line.

    Example:

    Var Fptr : File

    fAssign (Fptr, 'TEST.DAT', 66)

    fReset(Fptr)

    If IORESULT = 0 Then Begin

       If fPos(Fptr) = FSize(Fptr)

          WriteLn ('END OF FILE.')

       End

       fClose (fPtr)

    End

    The above example opens the file "TEST.DAT" for binary and then

    writes to the screen if the file position is at the end of the

    file.  The above statement "fPos(Fptr) = fSize(Fptr)" is the same

    as "fEof(Fptr)" since it's stating "if the file position is equal to

    the total file size, then we're at the end of the file."

Function FSIZE (File) : LongInt

    This function returns the total file size of an opened file.  The

    passed Handle is the file handle number used when the file was

    opened.  This function only works with files that have been opened

    as Binary since Text files are read line by line.

    Example:

    Var Fptr : File

    fAssign (Fptr, 'TEST.DAT', 66)

    fReset(Fptr)

    If IoResult = 0 Then

        WriteLn ('This file is ', fSize(Fptr), ' bytes in size.')

    fClose (Fptr)

    The above example opens the file "TEST.DAT", writes the size of

    the file to the screen, and then closes the file.

Procedure FASSIGN (Fptr : File, Mask : String, Attr : Int)

    This procedure opens a text or binary file for file operations.

    Fptr  : The passed file pointer is the file reference, of type FILE

    Mask  : The path and filename of the file to open, in string format.

    Attr  : File attributes to open.  See FINDFIRST for more info.

    EXAMPLE:

    Var Fptr : File  

    fAssign (Fptr, 'BLAH.TXT', 66)

    fReWrite (Fptr)

    fWriteLn (Fptr, 'Hello World!')

    fClose (Fptr)

    The above example creates a text file under the name 'BLAH.TXT'.

    If BLAH.TXT already exists, it will be erased and replaced by a

    new BLAH.TXT file.  The FWriteLn writes the text "Hello World" to

    the file, and then FClose closes the file.

Procedure FRESET (File)

    This procedure moves the file pointer to the beginning of an already

    opened file.  This is useful for moving the file pointer to specific

    spots in the file, without having to close and reopen the file.  The

    file must have previously been opened by FASSIGN.

    Use IORESULT to determine if the freset command was successful.

    Var fPtr : File

    fAssign(Fptr,CfgDataPath+'somefile.dat',66)

    fReset(Fptr)

    If IORESULT = 0 Then Begin

       WriteLn('somefile.dat is opened for use!')

       WriteLn('closing somefile.dat!')

       fClose(Fptr)

    End Else

       WriteLn('Unable to open somefile.dat')

     

Procedure FREWRITE(File)

    This procedure will this will erase an existing file and recreate it,

    leaving the file position at the beginning of the file.  If the

    file does not already exist, MPL will create the file.  The file must

    have previously been opened by FASSIGN.

Procedure FSEEK (Fptr: File, Position: LongInt)

    This procedure seeks to a file position in a binary file.  It

    will only work on binary files, not text file.

    Fptr : The passed file pointer value of type FILE

    Position : This is the position where FSEEK will seek to.

    EXAMPLE:

    Var Str : String

    Var Fptr: File

    Str := 'Hello World!'

    fAssign   (Fptr, 'BLAH.DAT',66)

    fSeek     (Fptr, FileSize(1))

    fWriteRec (Fptr, Str, 12)

    fClose    (Fptr)

    The above example opens an already existing file under the name

    'BLAH.DAT'.  Using FSEEK, it will seek to the end of the file,

    so that "Hello World" can be added as the last record.

Procedure FREAD (File, Str, Int)

    This procedure is used to read binary data from a file.

    Type FileInfo = record

       Index : Integer

       Name  : String [50]

       Data  : Integer

    End

    Var fptr : File

    Var info : FileInfo

    Var Recno: Integer = 3

    fAssign(Fptr,'FILE.DAT',66) // Open the file

    fReset(Fptr) // Reset to the beginning of the file

   If IoResult = 0 Then Begin  // If successful...

      fSeek(Fptr,(Recno-1)*SizeOf(Info)) // Go to 3rd record in the file

      If Not fEof(Fptr) Then // If the 3rd record is there...

         fRead(Fptr,Info,SizeOf(Info)) // Read the record

         // Optionally, use FreadRec(Fptr,Info) when reading record types.

    End

    fClose(Fptr) // close the file

Procedure FREADLN(File,Str)

    This procedure will read string data from a text file.

    Var fptr : File

    Var Str  : String

    fAssign(Fptr,'somefile.txt',66)

    fReset(Fptr)

    If IoResult = 0 Then Begin

       While Not fEof(Fptr) Do Begin

          FReadLn(Fptr,Str)

          WriteLn(Str)

       End

       fClose(Fptr)

    End

Procedure FWRITE (File, Str, Int)

    This procedure is used to write binary data to a file.

    Type FileInfo = record

       Index : Integer

       Name  : String [50]

       Data  : Integer

    End

    Var fptr : File

    Var info : FileInfo

    info.Index:=1

    info.Data:=33

    info.Name:='newname'

    fAssign(Fptr,'FILE.DAT',66)

    fReWrite(Fptr)

    fWrite(Fptr,Info,SizeOf(Info))

    fClose(Fptr)

Procedure FWRITELN(File,Str)

    This procedure is used to save string data to a text file.

    Var Fptr : File

    Var Str  : String = 'I am a string value!'

    fAssign(Fptr,'flatfile.txt',66)

    fReset(Fptr)

    If IoRESULT = 0 Then Begin

       // File already exists.

       // Seek to the end of the file.  aka append to the file

       fSeek(Fptr,FSize(Fptr))

    End Else Begin

       // File is not yet created.  Create it now.

       fReWrite(Fptr)

    End

    fWriteLn(Fptr,Str)

    fClose(Fptr)

Function SIZEOF (Type) : LongInt

    This function will take any named data type as input, and return

    the size of the data.

    Type TypeOfData = Record

      N : Integer

      L : Real

      V : LongInt

      Q : String [32]

    End

    Var I : Integer

    Var S : String [50]

    Var R : Real

    Var T : TypeofData

    WriteLn('Size Of I = '+Int2Str(SizeOf(I)))

    WriteLn('Size Of S = '+Int2Str(SizeOf(S)))

    WriteLn('Size Of R = '+Int2Str(SizeOf(R)))

    WriteLn('Size Of T = '+Int2Str(SizeOf(T)))

-----------------------------------------------------------------------

BBS Related Functions and Procedures

-----------------------------------------------------------------------

Function ACS (S: String) : Boolean

    This function processes an ACS string and returns true if the user

    has passed.

    Example:

    If ACS('s10g1') Then

         WriteLn ('You have access to this.')

    Else

         WriteLn ('Sorry, you do not have access.')

    The above example checks to see if the user passes the ACS string

    of "s10g1" and prints the result to the screen.

Function DATESTR (DT: LongInt, dType: Byte) : Integer

    This function will take a packed datetime number and convert it to

    a date string.  The dType parameter is used to set the format of the

    date which is returned.  Valid types are:

         UserDateType  = Returns date in the users date format

         1 = Returns date in format: MM/DD/YY

         2 = Returns date in format: DD/MM/YY

         3 = Returns date in format: YY/DD/MM

    Example:

    GetThisUser

    WriteLn ('Welcome.  You last called on ', DateStr(UserLast))

    The above example loads the currently logged in user's information

    into the USER variables using GETTHISUSER, then displays the last

    time the user has called to the screen using the DATESTR procedure.

Function DATETIME : LongInt

    This function returns the current Date and Time in the packed

    format.  DATESTR and TIMESTR can be used to convert this value

    into strings.

    Example:

    WriteLn ('Current Date: ', DateStr(DateTime), 0)

    WriteLn ('Current Time: ', TimeStr(DateTime), 1)

    The above example outputs the current date and time to the screen

    using the DATESTR and TIMESTR functions.  The DateTime function

    which is passed to DATESTR and TIMESTR, contains the current date

    and time in the packed format.

Function DIREXIST (S : String) : Boolean

    This function returns TRUE or FALSE if a directory exists.

    If DirExist('C:/MYSTIC/TEMP46') Then

       WriteLn('Dir C:/MYSTIC/TEMP46 exists!')

    Else

       WriteLn('Dir C:/MYSTIC/TEMP46 does not exist!')

Procedure DISPFILE (FN: String)

    This procedure displays a text or ANSI file to the screen.  If a

    path not included in the passed filename, Mystic will look for

    the file in the language text file directory.  If no file

    extension is provided in the passed file name, Mystic will display

    the correct file according to the user's graphics settings

    (ie .ANS for ANSI, .ASC for non-ansi).

    Example:

    DispFile ('WELCOME')

    The above example will display the text file "WELCOME" from the

    language text file directory.  Since there is no file extension

    provided, Mystic will display "WELCOME.ANS" or "WELCOME.ASC"

    depending on what the user's terminal settings are.

Procedure FILLCHAR (R : Record; S : Integer; V : Value )

    Fillchar fills the memory starting at X with Count bytes or

    characters with value equal to Value.

    type

    myuserrecord = record

      username  : string[30];

      somevalue : array[1..5] of byte;

    end;

    var

      u : myuserrecord;

    begin

      fillchar(u, sizeof(u), #0);

    end.

Procedure GETCFG

    This procedure will load the current configuration data into the

        CFG variables.  The "USES CFG" command must be used at the start

        of your program for GETCFG to work.  The following variables will

        be loaded:

    CFGSYSPATH     : System Path

    CFGDATAPATH    : Data Path

    CFGMSGSPATH    : Message Base Path

    CFGPROTPATH    : Protocol Path

    CFGQWKPATH     : Local QWK Path

    CFGMPEPATH     : Script (MPE) Path

    CFGATTPATH     : File Attach Path

    CFGLOGSPATH    : System Logs Path

    CFGTEXTPATH    : Text Files Path (for the current language)

    CFGTEMPPATH    : Temp path for the current node

    CFGMENUPATH    : Menu Files Path (for the current language)

    CFGTIMEOUT     :

    CFGSEEINVIS    : Gives the "See Invisible" ACS value

    CFGTNNODES     : Number of max telnet nodes to allow

    CFGNETDESC[1..30]     : Give the network descriptions.

    Example:

        Uses CFG

        GetCFG

    WriteLn ('Mystic BBS is installed in ', CfgSysPath)

    The above example will load the configuration into the CFG

    variables, and then print the directory where Mystic BBS is

    installed in to the screen.

Function GETATTRXY (X, Y : Byte) : Byte

    This function returns the attribute of the character at position

    XY on the user's screen:

    Var Attr : Byte;

    Attr := GetAttrXY(1, 1);

    WriteLn ('The attribure of the character at 1,1 is: ' + strI2S(Attr));

Function GETCHARXY (X, Y : Byte) : Char

    This function returns the character located on the user's

    screen at the XY location.

    Var Ch : Char;

    Ch := GetCharXY(1, 1);

    WriteLn('The user has the following character at 1,1: ' + Ch);

    This kind of stuff could allow you to create MPL-based custom screen

    effects like TheDraw used to have, except for on-the-fly with whatever

    is on the user's screen.

Function GETMBASE (N : Word) : Boolean

    This procedure will read message base data into the MBASE variables.

    The supplied N is the record number to read.  The function will

    return TRUE if the record was read successfully, or FALSE if the

        record was not read.  The "USES MBASE" command must be called at

        the start of your program for the MBASE functions to work

        correctly.

    The following MBASE variables will be set when a record is read:

    Variable Name   Type     Description

    -------------------------------------------------------------------

    MBASENAME      String    Name

   MBASEACS       String    ACS level

   MBASERACS      String    Read ACS level

   MBASEPACS      String    Post ACS level

   MBASESACS      String    SysOp ACS level

   MBASEINDEX     Integer   Index number (*NEVER* change this)

    Example:

    Var A Word

    A := 1

    While GetMBase Do

    Begin

         WriteLn ('Base name: ', MBaseName)

         A := A + 1

    End

    The above example will list all available message base systems on

    the BBS.

Function GETMBASESTATS (Base : LongInt; B1, B2 : Boolean; Tot, New, Yours : LongInt) : Boolean

     This can be used as a function or a procedure (returning true if

     successful).  It takes 6 parameters.

     #1: Message base number

     #2: Exclude messages FROM the current user in stats

     #3: Exclude messages TO the current user that have already been read

     #4: Total messages (this is a VAR parameter)

     #5: New messages (this is a VAR parameter)

     #6: New messages to you (this is a VAR parameter)

     Example:

     uses mbase;

     var

       count, total, new, yours : longint;

     begin

     count := 1;  //start @1 to skip email base

     while getmbase(count) do begin

       getmbstats(count, true, true, total, new, yours);

       writeln('base       : ' + mbasename);

       writeln('total msgs : ' + int2str(total));

       writeln('new msgs   : ' + int2str(new));

       writeln('your msgs  : ' + int2str(yours));

       writeln('');

       count := count + 1

     end;

Function GETMBASETOTAL (Compress : Boolean) : LongInt

    This function returns the total message bases on the system.  If

    Compressed is true, then it will return the total number of message

    bases the user has access to (slower to calculate).  If it is false,

    it returns the raw total number of bases on the system.

Function GETPROMPT (N : Word) : String

    This function will return a prompt from the current user's language

    file.  The passed N varliable is the prompt number to return.

    Example:

    WriteLn(GetPrompt(1))

    The above example writes prompt #1 from the user's currently

    selected language file to the screen.

Procedure GETSCREENINFO (I, X, Y, Attr : Integer)

    This allows you to read Mystic's internal ScreenInfo codes,

    used in Templates - so your MPLs can easily have templates

    just like Mystic!  These are the |!X codes.

Var

  X, Y, Attr : Byte;

Begin

  GetScreenInfo(1, X, Y, Attr);

  WriteLn('The value of the !1 MCI code was:');

  WriteLn('   X: ' + Int2Str(X));

  WriteLn('   Y: ' + Int2Str(Y));

  WriteLn('Attr: ' + Int2Str(Attr));

End;

Function GETUSER (N: Integer) : Boolean

    This procedure will read user data into the USER variables.  The

    supplied N is the record number to read.  The function returns

    true if the record was read, or false if a record was not read.

    The following USER variables will be set when a record is read:

    Variable Name   Type     Description

    -------------------------------------------------------------------

    USERDELETED     Boolean  Is the user marked as deleted?

    USERNAME        String   User's real name.

    USERALIAS       String   User's BBS alias.

    USERPASSWORD    String   User's password.

    USERADDRESS     String   User's street address.

    USERCITY        String   User's City/State.

    USERBIRTHDAY    String   User's birth date.

    USERSEX         Char     User's gender (M = Male, F = FeMale).

    USERSEC         Byte     User's security level (0-255).

    USERFIRSTON     LongInt  User's date/time of first call to the BBS.

                             This is stored in the packed date format

                             so in order to display the date & time,

                             the functions of DATESTR and TIMESTR need

                             to be used.

    USERLASTON      LongInt  User's date/time of the last call to the

                             BBS.  This is also stored in a packed date

                             format, so the same rules for USERFIRST

                             apply to this.

    -------------------------------------------------------------------

    Example:

    Var A Integer

    A := 1

    While GetUser(A) Do

    Begin

         WriteLn ('User Alias: ', UserAlias)

         A := A + 1

    End

    The above example will list all user accounts on the BBS system.

Procedure GETTHISUSER;

    This procedure loads the user information for the currently

    logged in user into the USER variables.  See the GETUSER function

    for a reference of the USER variables.

    Example:

    GetThisUser

    WriteLn ('Welcome to this BBS, ', UserAlias)

    WriteLn ('You have called ', UserCalls, ' times!')

    The above example will load the currently logged in user

    information into the user variables, then display a line of

    text welcoming them to the BBS.

Function GRAPHICS : Byte

    This function returns the user's current graphics mode in

    numerical format:

         0 = ASCII graphics mode

         1 = ANSI graphics mode

    Example:

    If Graphics = 1 Then

         WriteLn ('ANSI graphics')

    Else

         WriteLn ('ASCII graphics')

    The above example will print the user's current graphics mode

    to the screen.  If the user has ANSI (graphics mode 1), "ANSI

    graphics" will be printed.  If the user does not have ANSI

    (graphics mode 0), "ASCII graphics" will be printed to the screen.

Procedure HANGUP

    This procedure will stop the program immediately, hangup up on the

    user, and return Mystic BBS to the waiting for caller screen.

    Example:

    If InputYN ('Do you want to hangup now? ') Then

         HangUp

    The above example will prompt the user with a Yes/No question

    asking "Do you want to hangup now?" and if the user responds

    "Yes", they will be logged off the BBS using the HangUp command.

Function JustFile (S : String) : String

    This function takes a string arguement and returns only the

    filename:

    WriteLn ('This MPX filename is: ' + JustFile(ProgName));

Function JustFileName (S : String) : String

    This function  takes a string arguement and returns only the base

    filename (ie, not the extension so it basically just removes a file

    extension).  This does not remove a path, JustFile does that.

    WriteLn ('This MPX filename is: ' + JustFileName(ProgName));

Function JustPath (S : String) : String

    This function takes a string arguement and returns only the

    path (including the trailing backslash).

    Ex:

    WriteLn ('This MPX is located in ' + JustPath(ProgName));

Function LOCAL : Boolean

    This function returns TRUE if the user is logged into the BBS

    system locally.  It will return FALSE if the user is connected

    via a remote location.

    Example:

    If Local Then

      WriteLn ('Local caller detected.')

    Else

      WriteLn ('Remote caller detected.')

Function MSGEDITOR(0,Int,Int,Int,Bool,Str,Str) : Bool

Procedure MSGEDITSET(Int,Str)

Procedure MSGEDITGET(Int,Str)

     Added 3 new MPL functions: MsgEditor, MsgEditSet, MsgEditGet.  These

     allow access to the internal Mystic msg editor (line and/or full)

     from within MPL.  It even allows you to define wrap position and

     template to completely make it look like its not the Mystic editor!

     As a little hint the MsgEditSet and MsgEditGet stuff could be used to

     post process message text on posts.  Like say for example you wanted

     to write a MPL that allows users to add Tag lines, you could do that

     by replacing the "Saving message..." prompt and using those two in

     order to modify the text before it is saved by Mystic!

     Rather than trying to explain it all, here is an example of all 3:

Var

  Lines    : Integer = 0;

  WrapPos  : Integer = 79;

  MaxLines : Integer = 200;

  Forced   : Boolean = False;

  Template : String  = 'ansiedit';

  Subject  : String  = 'My subject';

  Count    : Integer;

Begin

  MsgEditSet (1, 'this is line 1');

  MsgEditSet (2, 'this is line 2!');

  Lines := 2;

  SetPromptInfo(1, 'MsgTo');  // if template uses &1 for "To:" display

  If MsgEditor(0, Lines, WrapPos, MaxLines, Forced, Template, Subject) Then Begin

    WriteLn('User selected to save.');

    WriteLn('There are ' + Int2Str(Lines) + ' of text in buffer:');

    For Count := 1 to Lines Do

      WriteLn(MsgEditGet(Count));

    Pause;

  End Else Begin

    WriteLn('User aborted the edit.');

    Pause;

  End

End

Procedure MENUCMD (CM: String, Data: String)

    This procedure will allow menu commands to be ran from within a

    program.  <CM> is the menu command, and <DATA> is the menu command

    data.

    Example:

    MenuCmd ('NW', '')

    The above example will run the menu command "NW" with the optional

    data field set to nothing.  This example will display the Who's

    Online list.  See MYSTIC.DOC for a list of all available menu

    commands.

Function NODENUM : Byte

    This function returns the current node number which the program

    is being ran on.

    Example:

    WriteLn ('Welcome to node number ', NodeNum)

    The above example will print the text "welcome to node number x"

    to the screen, where the x will be the current node number which

    the program is being ran on.

Variable PROGNAME : String

    Returns the path and filename of the current MPL program

Variable PROGPARAMS : String

    Returns any of th eparameters passed to the MPL program as a

    single string

Procedure PUTMBASE

    This procedure will save the currently loaded MBASE variables into

    a message base record.  See the GETMBASE function for a list of

    valid MBASE variables.

    Example:

    If GetMBase(1) Then Begin

         MBaseName := 'Message Base #1'

         PutMBase(1)

    End

    The above example will read the data for message base #1, set the

    name to "Message Base #1" and write the data back to the data file.

Procedure PUTTHISUSER

    This procedure will save the USER variables into the currently

    logged in user's record.  See the GETUSER function for a list of

    the USER variables which are saved by the PutThisUser function.

    Example:

    GetThisUser

    WriteLn ('Welcome ', UserAlias, '.  Your account is being deleted.')

    UserDeleted := True

    PutThisUser

    HangUp

    The above example will load the USER variables with the currently

    logged in user's information, then mark them as deleted with the

    UserDeleted variable.  Their account is then saved with the

    PutThisUser procedure and then they are hangup on using the HangUp

    command.

Procedure PUTUSER (N: Integer)

    This procedure will save the USER variables into the user file.

    The passed N parameter is the record number to save under.  See

    the GETUSER function for a list of the USER variables which are

    saved by the PutUser procedure.

    Example:

    If GetUser(1) Then

    Begin

         UserDeleted := True

         PutUser(1)

    End

    The above example will attempt to load the data from user record

    1 into the USER variables.  If the data is loaded without any

    errors, it will mark the user as deleted using the USERDELETED

    variable, and then save the record back to the user file.

Function READENV (S : String) : String

    This function returns the value of the given environment variable

    of the operating system.

Function REAL2STR(Real,Int):String

    This takes a string and decimal place value.

    Ex:

    Var

      R : Real;

    Begin

      R := 1234.1234;

      WriteLn (Real2Str(R, 2));  // Will print 1234.12

   End

Procedure SYSOPLOG (S: String)

    This procedure will add a line into the sysop log file found in

    the logs directory.

    Example:

    SysopLog ('User ran this program.')

    The above example will write the text "User ran this program" in

    the system log file, using the same format as Mystic uses in the

    log files (ie, the date and time will automatically be added).

Function TIMESTR (DT: LongInt, Mode: Byte)

    This function converts a packed datetime number into a time

    string.  The passed mode variable defines the format of the time

    string returned.  Valid options are:

         0 = 24 hour format: HH:MM:SS

         1 = 12 hour format: HH:MMa or HH:MMp

    Example:

    WriteLn ('The current time is: ', TimeStr(DateTime, 1))

    The above example outputs the current time to the screen using the

    TIMESTR and DATETIME functions.

Procedure UPUSER (Sec: Byte)

    This procedure will upgrade the currently logged in user's

    security level using the validation system.  The passed value

    is the security level to upgrade to and must be between the

    range of 0 to 255.

    Example:

    WriteLn ('Upgrading your access to level 20')

    UpUser (20)

    The above example will do a validation upgrade to the security

    level of 20.

-----------------------------------------

Other Supported Functions and procedures:

-----------------------------------------

Commands WITHOUT the ** DONE after them have not yet been documented above.

Hopefully all the commands are listed below, but it's possible that I could

have forgot a couple...  These docs will be up-to-date as time goes on! :)

ABS        ** DONE

ACS        ** DONE

ADDSLASH   ** DONE

ALLOWARROW ** DONE

CHR        ** DONE

CLRSCR     ** DONE

CONST

COPY       ** DONE

DATESTR    ** DONE

DATETIME   ** DONE

DELAY      ** DONE

DELETE     ** DONE

DISPFILE   ** DONE

DOSERROR   ** DONE

FEOF          ** DONE

FCLOSE        ** DONE

FCOPY         ** DONE

FILEERASE     ** DONE

FILEEXIST     ** DONE

FOPEN         ** DONE

FPOS          ** DONE

FSIZE         ** DONE

FINDCLOSE     ** DONE

FINDFIRST     ** DONE

FINDNEXT      ** DONE

FREAD

FREADLN

FREADREC

FSEEK         ** DONE

FUNCTION

FWRITE

FWRITELN

FWRITEREC

GETCFG        ** DONE

GETFBASE

GETMBASE      ** DONE

GETPROMPT     ** DONE

GETUSER       ** DONE

GETTHISUSER   ** DONE

GOTOXY        ** DONE

GRAPHICS      ** DONE

HALT          ** DONE

HANGUP        ** DONE

INPUT         ** DONE

INPUTNY       ** DONE

INPUTYN       ** DONE

INSERT        ** DONE

INT2STR       ** DONE

ISARROW       ** DONE

ISNOFILE      ** DONE

KEYPRESSED    ** DONE

LENGTH        ** DONE

LOCAL         ** DONE

LOWER         ** DONE

MENUCMD       ** DONE

MOVEX         ** DONE

MOVEY         ** DONE

NODENUM       ** DONE

ONEKEY

ONEKEYRANGE   ** DONE

ORD           ** DONE

PADCT         ** DONE

PADLT         ** DONE

PADRT         ** DONE

PARAMCOUNT    ** DONE

PARAMSTR      ** DONE

POS           ** DONE

PUTFBASE

PUTMBASE      ** DONE

PUTTHISUSER   ** DONE

PUTUSER       ** DONE

RANDOM        ** DONE

READKEY       ** DONE

SETPROMPT

SETUSERTIME

STATUSMODE

STATUSUPDATE

STR2INT       ** DONE

STRIPMCI      ** DONE

STRREP        ** DONE

STUFFKEY      ** DONE

SYSOPLOG      ** DONE

TIMER         ** DONE

TIMESTR       ** DONE

UPPER         ** DONE

UPUSER        ** DONE

USES

WHEREX        ** DONE

WHEREY        ** DONE

WORDCOUNT     ** DONE

WORDGET       ** DONE

WORPOS        ** DONE

WRITE         ** DONE

WRITELN       ** DONE