READ

Purpose: Load numeric values from a file into memory locations.

Format:    READ   memory location   num    file position

Notes:     The  READ  function reads a total of  num   values starting at file position  and places those values into memory locations starting at  memory location.  Parameters may be constants or variables.  The values read may consist of  bytes, integers or floating point depending on the format specified by the  preceeding OPEN  statement. file position is expressed in elements, not bytes. For example:  If the data type  is floating point then the 10th element is 40 bytes from beginning of the file. If file position  is larger than the actual file size an error will occur.

Examples:

# Read and display 20 values from a file
# Create a 16K file for demonstration

a = 0
loop begin 16384
memory(a) = sqrt(a)
a = a + 1
loop end
open demo.flt flt
write 0 16384 0

input file_pos " File starting position: "

# Then read 20 consecutive values into memory
# starting at location 100

read 20 100 file_pos

# Print out Results

print "   File     Table"
print " Position  Location  Value  "
print "----------------------------"

a = 100
lines = 20

*print_out

data = memory(a)
print "   " file_pos "      " a "    " data
a = a + 1
file_pos = file_pos + 1

lines = lines - 1
if lines > 0
goto print_out
endif

pause
exit

See Also:  MEMORY   OPEN    WRITE