ELib, Lowlevel and other miscelaneous procedures

ELib contains some lowlevel functions not included in the RTL. Some portable equivalents have been provided

ELib also contains some experimental/obsolete procedures, procedures not mentioned in the help are probably experimental.



PROCEDURES



FillCard

Declaration

PROCEDURE FillCard(var x;count : LONGINT;value : cardinal);

Description

FillChar, FillWord, and.....
Yes, FillCard. Fill memoryblock starting on address X with Count times value. So a block 4*Count will be filled because CARDINAL is 4 bytes wide. Can also be used for filling with a longint, but you'll need a typecast for that.



ScanR

Declaration

FUNCTION ScanR(VAR Adr;Value : BYTE;Count: LONGINT):LONGINT;

Description

Search for byte Value in memory block starting on address adr, for maximal Count bytes. Returns zero-based offset with respect to adr, or -1 when Value isn't found.

Note: Pascal'ed rep scasb function. Adr is VAR but not written.



ISqrt

Declaration

FUNCTION ISqrt(Indata:CARDINAL):CARDINAL;

Description

Equivalent to ISqrt:=Trunc(SQR(Float(InData)));

Square root of Indata rounded down. Entirely integer, no reals used. Old 386sx trick, and my first 32-bits code :-) Probably not faster than copro anymore, since it uses a loop. Assembler root is one instruction.



GetKey

Declaration

FUNCTION GetKey:WORD;

Description

This is the oldest procedure in entire XTDLIB. It's a shell to the Crt ReadKey procedure, which avoids problems with function keys. Function keys (like F1) are returned to ReadKey as two characters, the first being zero. GetKey simply calls ReadKey, and if ReadKey is zero, it calls ReadKey again and returns the second readkey SHL 8.

Note : Keys.inc contains some standard values for GetKey



SetCursorSize

Declaration

PROCEDURE SetCursorSize(A:WORD);

Description

Set cursorsize, the high byte is the first scanline, the low byte the last (lowest) scanline. A form of this procedure is included in Crt (SetCurSize($090A) is the same as Crt.CursorOn, and SetCurSize($FFFF) as CursorOff) but not exported.

EWindow uses this procedure and GetCursorSize to save and restore cursorsettings when changing windows.

Another application is to save deviating cursorshapes before shelling to dos, and restore afterwards



GetCursorSize

Declaration

FUNCTION GetCursorSize:WORD;

Description

Stores the cursorshape in a word. The high byte is the first scanline, the low byte the last (lowest) scanline.

EWindow uses this procedure and SetCursorSize to save and restore cursorsettings when changing windows.

Another application is to save deviating cursorshapes before shelling to dos, and restore afterwards



MAX

Declaration

FUNCTION Max(A:Something):Something;

with Something=BYTE,INTEGER,WORD,LONGINT,CARDINAL

Description

Returns the highest possible positive value for the specified type.

This is an internal of Modula2, but you can't implement it the same way without compiler support

Modula2 wayMAX(WORD); returns 65535
FPC wayMAX(WORD(x)); returns 65535

The value of 'x' is unimportant