Loc ( Returns The Current Logical Location Within A File ) - Mitsubishi QD51 Programming Manual

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

11 INSTRUCTIONS AND FUNCTIONS
LOC
Function
• Returns the current logical location within a file.
LOC ( <file number> )
Syntax
file number
PRINT LOC(1)
Examples
• The LOC function returns the current logical location within a file.
Description
• The value returned by the LOC function will differ depending on the type of the specified
file in <file number>.
For sequential files
The number of records that have been read/written (one record = 256 bytes) since the file
was opened will be returned as the function value.
For random files
The record number accessed last by the GET or PUT instruction will be returned as the
function value.
Program Example
10 ' Finds the record number in which data is written to a random file
20 OPEN "LOC.DAT" AS #1
30 FIELD #1,8 AS CS$, 10 AS AR$, 4 AS CL$, 10 AS NA$
40 INPUT "CALLSIGN";C$:LSET CS$=C$
50 INPUT "AREA ";A$:LSET AR$=A$
60 INPUT "CLASS ";B$:LSET CL$=B$
70 INPUT "NAME ";N$:LSET NA$=N$
80 PUT #1
90 PRINT LOC(1); "Station number"
100 INPUT "Continue registration? (Y/N)";Y$
110 IF Y$="Y" OR Y$="y" THEN 40
120 CLOSE #1
11 - 132
LOCation
• • • •
• • • •
REMARK
See the EOFand LOF functions.
Specify the file number of the file in order to detect its
current location.
If file number 1 is a sequential file, the location will be
displayed in increments of 256 bytes. If file number 1
is a random file, the record number last accessed will
be displayed.
:
' Opens the file
:
' Assigns a variable region in the random
file buffer
:
' Enters data
:
' Writes to file
:
' Displays record number written by the
PUT instruction
:
' Y or N is input
:
' Continues registration if Y
:
' Closes the file
MELSEC-Q
11 - 132

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents