{{fbdoc item="title" value="LOCATE"}}----
Sets the current cursor position

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Locate**( //row// [[KeyPgAs|as]] [[KeyPgLong|long]] = 0, //column// [[KeyPgAs|as]] [[KeyPgLong|long]] = 0, //state// [[KeyPgAs|as]] [[KeyPgLong|long]] = -1, //start// [[KeyPgAs|as]] [[KeyPgLong|long]] = 0, //stop// [[KeyPgAs|as]] [[KeyPgLong|long]] = 0 ) [[KeyPgAs|as]] [[KeyPgLong|long]]
##
{{fbdoc item="usage"}}##
	**Locate** [//row//], [//column//], [//state//]

	//result// = **Locate**( [//row//], [//column//], [//state//] )
	//new_column// = [[KeyPgLoByte|lobyte]]( //result// )
	//new_row// = [[KeyPgHibyte|hibyte]]( //result// )
	//new_state// = [[KeyPgHiword|hiword]]( //result// )
##
{{fbdoc item="param"}}
	##//row//##
		the 1-based vertical character position in the console.
	##//column//##
		the 1-based horizontal character position in the console.
	##//state//##
		the state of the cursor in console-mode only: ##0## is off, ##1## is on; text cursor is never visible in graphics mode.
	##//start//##
		Ignored. Allowed for //[[CompilerOptlang|-lang qb]]// dialect compatibility only.
	##//stop//##
		Ignored. Allowed for //[[CompilerOptlang|-lang qb]]// dialect compatibility only.

{{fbdoc item="ret"}}
	Returns a 32 bit ##[[KeyPgLong|Long]]## containing the current cursor position and state. The [[KeyPgLoByte|low byte of the low word]] contains the column, the [[KeyPgHibyte|high byte of the low word]] contains the row, and the [[KeyPgHiword|high word]] contains the cursor state.
	
	If any of the //row//, //column// or //state// parameters were just set by the call to ##**Locate**##, then the return value will reflect these new values, not the previous ones. If any of the parameters were omitted in the call to ##**Locate**##, then the return value will reflect the current values, which are the same as before the call to ##**Locate**##.
	
	##**Locate**## will attempt to position the cursor at the specified row and column. If the position is beyond the screen extents, cursor will not reposition. And next ##[[KeyPgPrint|Print]]## to the screen will continue at last valid cursor position.  When printing to the last line of the screen, and the ##[[KeyPgPrint|Print]]## statement has a new line character, the screen will scroll and reposition the cursor automatically to the last line, column 1.

{{fbdoc item="desc"}}
	Sets the text cursor in both graphics and console modes.

{{fbdoc item="ex"}}
	{{fbdoc item="filename" value="examples/manual/console/locate.bas"}}%%(freebasic)
locate 10
print "Current line:"; CSRLIN
%%
	
	{{fbdoc item="filename" value="examples/manual/console/locate-getmouse.bas"}}%%(freebasic)
'' Text cursor + mouse tracking
dim as integer x = 0, y = 0, dx, dy

cls
locate , , 1

while inkey <> chr(27)
	getmouse dx, dy
	if( dx <> x or dy <> y ) then
		locate y+1, x+1: print " ";
		x = dx
		y = dy
		locate 1, 1: print x, y, ""
		locate y+1, x+1: print "X";
	end if
wend
%%

{{fbdoc item="diff"}}
	- The ##//start//## and ##//stop//## arguments have no effect in ""FreeBASIC"".
	- QB will raise an error if ##//row//## or ##//column//## are beyond the screen extents.

{{fbdoc item="see"}}
	- ##[[KeyPgCsrlin|Csrlin]]##
	- ##[[KeyPgPos|Pos]]##
	- ##[[KeyPgPrint|Print]]##
	- ##[[KeyPgPrint|?]]##

{{fbdoc item="back" value="CatPgConsole|Console Functions"}}