• MPL Strings

    From Black Panther@1:396/4 to All on Friday, March 25, 2022 23:49:08
    From: nospam.Black.Panther@f3.n317.z1.fidonet.org (Black Panther)

    Hello g00r00!

    Just a quick question for you. I know that strings in MPL are 255 characters, but is there a way to have a string that is longer?

    The reason I'm asking, is I wrote a function that will take a text string, and wrap the text to the users terminal size. The problem I'm running into, is with
    the larger screen sizes, 255 characters isn't much longer than the screen.

    Would it be possible to have something like an ansistring in MPL, or would that
    cause issues with the memory limits of MPL?

    Thanks,

    Black Panther

    .... Trap $C0FFEE, insert coffeemachine to reboot
    --- NewsGate v1.0 gamma 2
    * Origin: News Gate @ Net396 -Huntsville, AL - USA (1:396/4)
  • From Shaun Buzza@1:396/4 to All on Saturday, March 26, 2022 05:55:32
    From: nospam.Shaun.Buzza@f110.n229.z1.fidonet.org (Shaun Buzza)

    Just a quick question for you. I know that strings in MPL are 255 characters, but is there a way to have a string that is longer?

    The reason I'm asking, is I wrote a function that will take a text
    string, and wrap the text to the users terminal size. The problem I'm running into, is with the larger screen sizes, 255 characters isn't much longer than the screen.

    Would it be possible to have something like an ansistring in MPL, or
    would that cause issues with the memory limits of MPL?

    Isn't 255 the limit for string size in all versions of Pascal? Yeah, I know MPL
    isn't exactly Passcal, but I would assume that it is constrained by the limits of Pascal itself...

    McDoob
    SysOp, PiBBS
    pibbs.sytes.net

    .... Message encrypted: Press ALT-F4 to read encoded message

    --- NewsGate v1.0 gamma 2
    * Origin: News Gate @ Net396 -Huntsville, AL - USA (1:396/4)
  • From Black Panther@1:396/4 to All on Saturday, March 26, 2022 04:25:16
    From: nospam.Black.Panther@f3.n317.z1.fidonet.org (Black Panther)

    Hello Shaun!

    25 Mar 22 22:55, you wrote to me:

    Isn't 255 the limit for string size in all versions of Pascal? Yeah, I know MPL isn't exactly Passcal, but I would assume that it is
    constrained by the limits of Pascal itself...

    At least in Free Pascal, there is a string type called AnsiString, which has no
    length limit. The string is null terminated, and is actually treated as a pointer to memory on the heap.

    There actually is a length limit, but it's dependent on the operating system and the amount of memory the computer has.

    I really only need a string that would be able to hold around 500 or so characters. I wonder if I could do that with an array of char... Hmmm


    Black Panther

    .... Necrophiliacs DO IT until they are dead tired.
    --- NewsGate v1.0 gamma 2
    * Origin: News Gate @ Net396 -Huntsville, AL - USA (1:396/4)
  • From g00r00@1:396/4 to All on Saturday, March 26, 2022 18:49:07
    From: nospam.g00r00@f215.n129.z1.fidonet.org (g00r00)

    Just a quick question for you. I know that strings in MPL are 255 characters, but is there a way to have a string that is longer?

    Your options for now are to use Mystic's Python integration or you can try using the MysticScript which does allow longer strings (available in the pre-alpha releases of A47 and A48). Otherwise I think you'd have to to use multiple strings or an array of chars in MPL.

    MPL was created in the 1990s and is missing a few crucial things most notably are 64-bit integers and an ansistring-like type. I may add them in the future but its going to be a bunch of work, so I am experimenting with MysticScript as
    a possible replacement instead.

    I haven't fully decided on which direction to go but you can find MS in the A48
    pre-alphas. The latest version includes Blackjack, Tetris, and the Usage ported to MysticScript.

    .... APPLE: It may be slow, but at least it's expensive.

    --- NewsGate v1.0 gamma 2
    * Origin: News Gate @ Net396 -Huntsville, AL - USA (1:396/4)
  • From Black Panther@1:396/4 to All on Sunday, March 27, 2022 07:18:08
    From: nospam.Black.Panther@f3.n317.z1.fidonet.org (Black Panther)

    Hello g00r00!

    26 Mar 22 11:49, you wrote to me:

    Just a quick question for you. I know that strings in MPL are 255
    characters, but is there a way to have a string that is longer?

    Your options for now are to use Mystic's Python integration or you can
    try using the MysticScript which does allow longer strings (available
    in the pre-alpha releases of A47 and A48). Otherwise I think you'd
    have to to use multiple strings or an array of chars in MPL.

    That's kinda what I was thinking, but figured it didn't hurt to ask. ;)

    I haven't fully decided on which direction to go but you can find MS
    in the A48 pre-alphas. The latest version includes Blackjack, Tetris,
    and the Usage ported to MysticScript.

    I might have to take a look at MS. Is the syntax similar to MPL? I guess if I took a look, I would be able to find out for myself... <smack> :)

    Thank you!


    Black Panther

    .... Civil engineers do it in the dirt.
    --- NewsGate v1.0 gamma 2
    * Origin: News Gate @ Net396 -Huntsville, AL - USA (1:396/4)
  • From g00r00@1:396/4 to All on Monday, March 28, 2022 18:32:49
    From: nospam.g00r00@f215.n129.z1.fidonet.org (g00r00)

    I might have to take a look at MS. Is the syntax similar to MPL? I guess if I took a look, I would be able to find out for myself... <smack> :)

    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.

    --- NewsGate v1.0 gamma 2
    * Origin: News Gate @ Net396 -Huntsville, AL - USA (1:396/4)