14.5.3 MOVE Statement
The MOVE statement defines data fields and moves them to
and from the record buffer created by BASIC. For example:
MOVE FROM #9%, A$, Cost, Name$ = 30%, ID_num%
This statement moves a record with four data fields from the
record buffer to the variables in the list as follows:
.
A string field A$ with a default length of 16 characters
.
A number field Cost of the default data type
.
A second 30-character string field Name$
.
An integer field ID_num%
Valid variables in the MOVE list are as follows:
Because BASIC dynamically assigns space for string vari-
ables, the default string length during a MOVE TO operation
is the length of the string. The default for MOVE FROM
is 16 characters. An entire array specified in a MOVE
statement must include the array name, followed by n - 1
commas, where n is the number of dimensions in the array.
Note that these commas must be enclosed in parentheses.
You specify a single array element by naming the array
and the subscripts of that element. The following statement
moves three arrays from the program to the record buffer.
A$ specifies a 1-dimensional string array, C specifies a 2-
dimensional array of the default data type, and D% specifies
a 3-dimensional integer array. B (3,2) specifies the element of
array B that appears in row 3, column 2.
MOVE TO #5%, A$(), C(,), D%(,,), B(3,2)
Successive MOVE statements to or from the buffer start at
the beginning of the record buffer. If a MOVE TO operation
only partially fills the buffer, the rest of the buffer is un-
changed. You use the GET statement to read a record from
a file, and then you move the data from the buffer to vari-
ables and reference the variables in your program. A MOVE
TO operation moves data from the variables into the buffer
created by BASIC. A PUT or UPDATE statement then moves
the data from the buffer to the file.
The following program opens file MOV.DAT, reads the first
record into the buffer, and moves the data from the buffer
into the variables specified in the MOVE FROM statement:
DECLARE STRING Emp_name, Address, Department
DECLARE LONG Badge
OPEN "MOV.DAT" AS FILE #1%, &
RELATIVE VARIABLE, &
ACCESS MODIFY, ALLOW NONE, &
RECORDSIZE 512%
GET #1%
MOVE FROM #1%, &
Emp_name = 25, &
Badge, &
Address = 25, &
Department = 4
.
.
.
MOVE TO #1%, &
Emp_name = 25, &
Badge, &
Address = 25, &
Department = 4
UPDATE #1%
CLOSE #1%
END
The MOVE TO statement moves the data from the named
variables into the buffer. The UPDATE statement writes the
record back into file MOV.DAT. The CLOSE statement closes
the file.