• MPL Bitwise Operators

    From LEE WESTLAKE@2:250/6 to All on Thursday, January 13, 2022 15:25:46
    Hi All,

    Is someone able to clarify as to how bitwise operators are implemented in MPL?

    For example: the expression "a := b xor c;" currently returns "Unknown identifier: xor"' during compilation.

    As always, any advice is greatly appreciated.

    o-----------o------------o-------------------------o
    TALIADON | 2:250/6 | 21:3/138 | TALIADON-BBS@MAIL.COM | o-----------o-----------o------------o-------------------------o
    | "Error is a great teacher, and humility its hardest lesson." | o--------------------------------------------------------------o

    --- Mystic BBS v1.12 A46 2020/08/26 (Windows/32)
    * Origin: TALIADON BBS (2:250/6)
  • From g00r00@1:129/215 to LEE WESTLAKE on Thursday, January 13, 2022 12:25:44
    Is someone able to clarify as to how bitwise operators are implemented
    in MPL?

    For example: the expression "a := b xor c;" currently returns "Unknown identifier: xor"' during compilation.

    MPL is supposed to support your typical bitwise operators (keywords and/or/xor/shl/shr) but clearly something is not working.

    There are also three functions that allow you to check, set, and toggle bits in any integer type that MPL supports which can be used for now until I figure out what happened.

    This is in a WHATSNEW from way back in 2011 (The number you pass is the actual bit you want to check, set or toggle ie 1-32)

    + New MPL function "BitCheck" 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');

    Note that this was implemented before actual bitwise math, which also
    made it into this version. Keep reading! :)

    + New MPL function "BitToggle" 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.

    + New MPL function "BitSet" 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

    ... What do you mean, QWK? It took me over an hour to read!

    --- Mystic BBS v1.12 A48 2022/01/12 (Windows/32)
    * Origin: Sector 7 * Mystic WHQ (1:129/215)
  • From Nick Andre@1:229/426 to G00R00 on Thursday, January 13, 2022 16:34:31
    On 13 Jan 22 12:25:44, G00R00 said the following to Lee Westlake:

    MPL is supposed to support your typical bitwise operators (keywords and/or/xor/shl/shr) but clearly something is not working.

    But...............................................

    .......................... does it have cowbell.

    Nick

    --- Renegade vY2Ka2
    * Origin: Joey, do you like movies about gladiators? (1:229/426)
  • From LEE WESTLAKE@2:250/6 to g00r00 on Thursday, January 13, 2022 23:35:48
    MPL is supposed to support your typical bitwise operators (keywords and/or/xor/shl/shr) but clearly something is not working.

    I certainly miss them when they're not there, but an arithmetic solution
    proved just as good.

    There are also three functions that allow you to check, set, and toggle bits in any integer type that MPL supports which can be used for now
    until I figure out what happened.

    This is in a WHATSNEW from way back in 2011 (The number you pass is the actual bit you want to check, set or toggle ie 1-32)

    + New MPL function "BitCheck" 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');

    Note that this was implemented before actual bitwise math, which also
    made it into this version. Keep reading! :)

    + New MPL function "BitToggle" 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.

    + New MPL function "BitSet" 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

    Thanks g00r00, I appreciate the additional information.

    o-----------o------------o-------------------------o
    TALIADON | 2:250/6 | 21:3/138 | TALIADON-BBS@MAIL.COM | o-----------o-----------o------------o-------------------------o
    | "Error is a great teacher, and humility its hardest lesson." | o--------------------------------------------------------------o

    --- Mystic BBS v1.12 A46 2020/08/26 (Windows/32)
    * Origin: TALIADON BBS (2:250/6)
  • From LEE WESTLAKE@2:250/6 to Nick Andre on Thursday, January 13, 2022 23:37:00
    But...............................................

    .......................... does it have cowbell.

    I need moooooore cowbell!

    o-----------o------------o-------------------------o
    TALIADON | 2:250/6 | 21:3/138 | TALIADON-BBS@MAIL.COM | o-----------o-----------o------------o-------------------------o
    | "Error is a great teacher, and humility its hardest lesson." | o--------------------------------------------------------------o

    --- Mystic BBS v1.12 A46 2020/08/26 (Windows/32)
    * Origin: TALIADON BBS (2:250/6)