User Tools

Site Tools


mpl_functions

This is an old revision of the document!


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

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.
mpl_functions.1468274072.txt.gz · Last modified: 2016/07/11 16:54 by gryphon

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki