home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.bbs.mystic      Mystic Sysops are mystical nerds...      11,842 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 10,714 of 11,842   
   g00r00 to All   
   Re: MPL Strings   
   28 Mar 22 11:32:49   
   
   From: nospam.g00r00@f215.n129.z1.fidonet.org   
      
    BP> I might have to take a look at MS. Is the syntax similar to MPL? I guess   
    BP> if I took a look, I would be able to find out for myself...  :)   
      
   Yes, it is Pascal-like and it has a lot of new language features too like   
   significantly better array handling, pointers, inheritance, overloading, no   
   string limitations, default parameters, 64 bit integers, etc.   
      
   You can use usage.mps and usage.ms in the latest A48 build to compare how close   
   the code is.  I can also give you this too (but keep in mind I am not 100% sure   
   I will use MS or not yet as the future MPL):   
      
   DIFFERENCES FROM TURBO/FREEPASCAL/MPL   
   =====================================   
      
   -- Boolean evaluations must be surrounded in parenthesis.  This works the same   
      as Turbo/Free Pascal but different than MPL.  In MPL allows multiple   
      evaluations to be defined without parenthesis like so:   
      
        MPL: If Deck[6].Card = CardJack or Deck[7].Card = CardJack Then   
      
      Mystic Script/Turbo/FreePascal:   
      
        If (Deck[6].Card = CardJack) or (Deck[7].Card = CardJack) Then   
      
   -- Function results must be assigned to "Result" not function name   
      
      Many Pascal compilers assign function results to the result variable not   
      the function name as in Turbo Pascal and MPL.  For example:   
      
      TurboPascal/MPL:   
      
      Function MyFunction : Byte;   
      Begin   
        MyFunction := 10;   
      End;   
      
      FreePascal/Delphi/Mystic Script:   
      
      Function MyFunction : Byte;   
      Begin   
        Result := 10;   
      End;   
      
   -- Case statements "Else" does not have an "assumed Begin/End"   
      
     Turbo Pascal:   
      
     Case 1 of   
       2: WriteLn('2');   
     Else   
       // Single statement here or multiple statements in Turbo Pascal are okay   
      
       WriteLn('Case else');   
       WriteLn('Value is not 2');   
     End   
      
     Mystic Script:   
      
     Case 1 of   
       2: WriteLn('2');   
     Else   
       // Single statement here is okay, but you must enclose multiple statements   
       // in a begin/end like this:   
       Begin   
         WriteLn('Case else');   
         WriteLn('Value is not 2');   
       End;   
     End;   
      
   -- Case statements function with string values now:   
      
        MyString := 'Hello';   
      
        Case MyString of   
          'Hello': WriteLn('Hello to you!');   
        End;   
      
        This would cause a syntax error in FreePascal or TurboPascal but it works   
        in Mystic Script.   
      
   -- Semi-colons as statement enders are stricter in Mystic Script.  MPL and   
      even Free Pascal is not as strict, so when porting code you may need to add   
      in some semicolons that you missed in your source code.  You need to have   
      the period after End. in your main program block to signify the end of the   
      script, etc.  There is no compilation so it is more strict with its syntax.   
      
   -- When defining default values for records or arrays they must be enclosed in   
      brackets ([]) instead of parenthesis.   
      
      Turbo Pascal:   
      
        MyArray : Array[1..4] of Byte = (1,2,3,4);   
      
      Mystic Script:   
      
        MyArray : Array[1..4] of Byte = [1,2,3,4];   
      
   -- Default values for a record do not require the element name.  Values should   
      be defined in order of appearance within the record:   
      
      Type   
        MyRec = Record   
          A : Byte;   
          B : Byte;   
        End;   
      
      Turbo Pascal:   
      
        Var R: MyRec = (A:0; B:0);   
      
      Mystic Script:   
      
        Var R: MyRec = [0,0];   
      
   -- Multi-dimensional arrays are not declared with TurboPascal shortcuts:   
      
      Mystic Script:   
      
        Var Grid: Array[1..40] of Array[1..40] of Byte;   
      
      TurboPascal/MPL:   
      
        Var Grid: Array[1..40, 1..40] of Byte;   
      
   -- String types are not limited to 255 characters in Mystic Script.   
      
   -- Shutdown must abort script exection.   
      
      In MPL scripts will automatically terminal when a shutdown happens but this   
      convience comes at the expense of being able to handle a shutdown event such   
      as a user disconnection.   
      
      Mystic Script works similar to Mystic Python in that the shutdown event   
      must be tested for and your script must exit when it is True.  This means   
      that all types of input that would stop the script must be enclosed in a   
      test for Shutdown.  For example:   
      
        Repeat   
          Write ('Menu Prompt (Q/Quit): ');   
      
          Case (Readkey) of   
            'Q' : Break;   
          End;   
        Until Shutdown;   
      
        // We get here when the user presses Q or Shutdown is True   
      
   ... Help! I can't find the "ANY" key.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca