Click or drag to resize

MemAtSpecial Function

Get the location of the first special console character in a buffer.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION MemAtSpecial(
	ptrBuffer AS IntPtr,
	dwCount AS DWORD
) AS DWORD
View Source

Parameters

ptrBuffer
Type: IntPtr
A pointer to a buffer.
dwCount
Type: UInt32
The number of bytes in <ptrBuffer> to check.

Return Value

Type: UInt32
The location of the first special console character within the specified portion of <ptrBuffer>.  If a special console character does not exist, MemAtSpecial() returns 0.
Remarks
Special console characters are characters with ASCII values less than or equal to 13, which can require special handling when displayed on the screen.  Moreover, a terminal driver can assign special meaning to them, such as ringing the bell when a Chr(7) is specified.
Examples
This example uses MemAtSpecial() iteratively to detect all special console characters in a string:
X#
FUNCTION Start()
        LOCAL s := "AB" + _Chr(10) + "CD" + _Chr(7) + ;
                        "EF" + _Chr(13) + "GH" AS STRING
        LOCAL wAt AS DWORD
        DO WHILE SLen(s) > 0
                wAt := MemAtSpecial(Ptr(_CAST, s), SLen(s))
                IF wAt > 0
                        ? "Special char with ASCII code of:",;
                                Asc(Substr3(s, wAt, 1)), "was detected"
                        // Query the rest of the string
                        // (from wAt+1 and on)
                        s := Substr(s, wAt+1)
                ELSE
                        s := ""
                ENDIF
        ENDDO
See Also