// Example of realtime retrieval of cursor coordinates

// Declare the Windows function for our use.
declare pfunc GetCursorPos returning integer in dll user.exe

// Declare a string the size of the POINT structure that GetCursorPos uses
// POINT is 2 integers, therefore 4 bytes.
lpStrArray = space(4)

store 0 to nXTemp, nYTemp

// loop until user hits ESC
do while lastkey() <> 27
	myevent = chkevent()
	do while myevent = -1
		myevent = chkevent()
		// call the function with a pointer to our 'string'
		GetCursorPos(@lpStrArray)
		// get the 1st integer (2 bytes) from the 'string', which is the X-coord.
		nXCoord = getint(@lpStrArray, 1)
		// get the 2nd integer (2 bytes) from the 'string', which is the Y-coord.
		nYCoord = getint(@lpStrArray, 2)
		if ((nXCoord <> nXTemp) .or. (nYCoord <> nYTemp))
			// always clear the position before painting
			@ 0,0 clear to 1,10
			@ 0,0 say alltrim(str(nXCoord))
			@ 0,5 say alltrim(str(nYCoord))
			nXTemp = nXCoord 
			nYTemp = nYCoord
		endif
	enddo
enddo

