LOC

From MCS Wiki AVR
(Difference between revisions)
Jump to: navigation, search
(Created page with "= <span class="f_Header">Action</span> = Returns the position of last read or written Byte of the file <span style="font-family: Arial;"> </span> <span style="font-fam...")
 
 
Line 48: Line 48:
 
= <span class="f_Header">See also</span> =
 
= <span class="f_Header">See also</span> =
  
[http://avrhelp.mcselec.com/initfilesystem.htm INITFILESYSTEM]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/open.htm OPEN]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/close.htm CLOSE],&nbsp;[http://avrhelp.mcselec.com/flush.htm FLUSH]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/print.htm PRINT],&nbsp;[http://avrhelp.mcselec.com/line_input.htm LINE INPUT],&nbsp;[http://avrhelp.mcselec.com/lof.htm LOF]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/eof.htm EOF]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/freefile.htm FREEFILE]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/fileattr.htm FILEATTR]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/seek.htm SEEK]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/bsave.htm BSAVE]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/bload.htm BLOAD]&nbsp;,[http://avrhelp.mcselec.com/kill.htm KILL]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/diskfree.htm DISKFREE]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/disksize.htm DISKSIZE]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/get.htm GET]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/put.htm PUT]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/filedate.htm FILEDATE]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/filetime.htm FILETIME]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/filedatetime.htm FILEDATETIME]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/dir.htm DIR]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/filelen.htm FILELEN]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/write.htm WRITE]&nbsp;,&nbsp;[http://avrhelp.mcselec.com/input.htm INPUT]
+
[[INITFILESYSTEM]] , [[OPEN]] , [[CLOSE]], [[FLUSH]] , [[PRINT]], [[LINE INPUT]], [[LOF]] , [[EOF]] , [[FREEFILE]] , [[FILEATTR]] , [[SEEK]] , [[BSAVE]] , [[BLOAD]] ,[[KILL]] , [[DISKFREE]] , [[DISKSIZE]] , [[GET]] , [[PUT]] , [[FILEDATE]] , [[FILETIME]] , [[FILEDATETIME]] , [[DIR]] , [[FILELEN]] , [[WRITE]] , [[INPUT]]
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>

Latest revision as of 22:06, 11 February 2013

Contents

Action

Returns the position of last read or written Byte of the file

 

 

Syntax

lLastReadWritten = LOC (#bFileNumber)

 

 

Remarks

bFileNumber

(Byte) File number, which identifies an opened file

lLastReadWritten

(Long) Variable, assigned with the Position of last read or written Byte (1-based)

 

This function returns the position of the last read or written Byte. If an error occurs, 0 is returned. Check DOS-Error in variable gbDOSError. If the file position pointer is changed with the command SEEK, this function can not be used till the next read/write operation.

 

This function differs from VB. In VB the byte position is divided by 128.

 

 

See also

INITFILESYSTEM , OPEN , CLOSE, FLUSH , PRINT, LINE INPUT, LOF , EOF , FREEFILE , FILEATTR , SEEK , BSAVE , BLOAD ,KILL , DISKFREE , DISKSIZE , GET , PUT , FILEDATE , FILETIME , FILEDATETIME , DIR , FILELEN , WRITE , INPUT

 

 

ASM

Calls

_FileLoc

 

Input

r24: filenumber

X: Pointer to Long-variable, which gets th result

Output

r25: Errorcode

C-Flag: Set on Error

 


 

Example


'open the file in BINARY mode
Open "test.biN" For Binary As #2
Put #2 , B ' write a byte
Put #2 , W ' write a word
Put #2 , L ' write a long
Ltemp = Loc(#2)+ 1 ' get the position of the next byte
Print Ltemp ;" LOC"' store the location of the file pointer
Print Lof(#2);" length of file"
Print Fileattr(#2);" file mode"' should be 32 for binary
Put #2 , Sn ' write a single
Put #2 , Stxt ' write a string
 
Flush #2 ' flush to disk
Close #2

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language