11 - 132 11 - 132
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
LOC
Function
LOCation
• Returns the current logical location within a file.
LOC ( <file number> )
Syntax
file number
• • • •
Specify the file number of the file in order to detect its
current location.
Examples
PRINT LOC(1)
• • • •
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.
Description
• The LOC function returns the current logical location within a file.
• 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
: ' Opens the file
30 FIELD #1,8 AS CS$, 10 AS AR$, 4 AS CL$, 10 AS NA$
:
' Assigns a variable region in the random
file buffer
40 INPUT "CALLSIGN";C$:LSET CS$=C$
: ' Enters data
50 INPUT "AREA ";A$:LSET AR$=A$
60 INPUT "CLASS ";B$:LSET CL$=B$
70 INPUT "NAME ";N$:LSET NA$=N$
80 PUT #1
:
' Writes to file
90 PRINT LOC(1); "Station number"
:
' Displays record number written by the
PUT instruction
100 INPUT "Continue registration? (Y/N)";Y$
:
' Y or N is input
110 IF Y$="Y" OR Y$="y" THEN 40
:
' Continues registration if Y
120 CLOSE #1
:
' Closes the file
REMARK
See the EOFand LOF functions.
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...