{{fbdoc item="title" value="LOC"}}----
Returns the file position where the last file read/write was performed

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Loc** ( [[KeyPgByval|byval]] //filenum// [[KeyPgAs|as]] [[KeyPgLong|long]] ) [[KeyPgAs|as]] [[KeyPgLongint|longint]]
##
{{fbdoc item="usage"}}##
	//result// = **Loc**( //filenum// )
##
{{fbdoc item="param"}}
	##//filenum//##
		The file number of an open file.

{{fbdoc item="ret"}}
	The file position where the last read/write was performed.

{{fbdoc item="desc"}}
	Returns the position where the last file read/write was performed.
	
	The position is indicated in records:
		In files opened FOR RANDOM the record length specified when file was opened is used
		In  text files (FOR INPUT|OUTPUT|APPEND, a record length of 128 bytes is supposed.
		In files opened for BINARY a 1 byte record length is used.
		
	In FreeBASIC the file position is 1 based, the first record of a file is record 1 (##**Loc**##=1 after reading or writing the first record, ##**Loc**##=0 for the start position in the file).
	
	When used with a serial device, ##**Loc**## returns the number of bytes waiting to be read from the serial device's input buffer.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/fileio/loc.bas"}}%%(freebasic)
dim b as string

if open com ("com1:9600,n,8,1,cs,rs,ds,bin" for binary as #1) <> 0 then
  print "unable to open serial port"
  end
end if

print "Sending command: AT"

print #1, "AT" + chr(13, 10);

sleep 500,1

print "Response:"

while( loc(1) > 0 )
  b = input(loc(1), 1)
  print b;
wend

close #1
%%

{{fbdoc item="diff"}}
	- None

{{fbdoc item="see"}}
	- ##[[KeyPgLof|Lof]]##
	- ##[[KeyPgEof|Eof]]##
	- ##[[KeyPgSeekreturn|Seek (Function)]]##
	- ##[[KeyPgOpen|Open]]##

{{fbdoc item="back" value="CatPgFile|File I/O Functions"}}