BASIC Moves Development Studio
06/2005
Danaher Motion
48 Rev
E
M-SS-005-03l
2.9.2.
OPEN #, INPUT #, CLOSE, LOC
See Serial port.
2.9.3.
TELL
Returns current file pointer, offset from the beginning of the file. Value has
meaning only for
SEEK
to move the file pointer within a file.
2.9.4.
SEEK
Moves file pointer to specified location. Use with
TELL
.
File operations example:
program
dim pos as long
dim d1 as double
dim s1 as string
'create file for writing
Open "test.prg" mode ="w" as #1
print #1, "1.2345"
close #1
'append to existing file
Open "test.prg" mode ="a" as #1
print #1, PI
close #1
'read from file
Open "test.prg" mode ="r" as #1
'how many characters in the file?
print "File contains ";loc(1);" characters"
s1 = input$(#1)
'convert from string to double
d1=val(s1)
?d1
'save current file pointer
pos = tell(#1)
?input$(#1)
'rewind file
seek (#1,pos)
?input$(#1)
close #1
end program
Output:
File contains 31 characters
1.23450000000
3.14159265300
3.1415926530