IBM Lotus Symphony
|
将相对文件中的记录或二进制文件中的字节序列读入变量。
另请参阅:PUT 语句
Get [#] FileNumber As Integer, [Position], Variable
FileNumber:确定文件号的任何整型表达式。
Position:对于采用 Random 方式打开的文件,Position 为要读取的记录号。
对于采用 Binary 方式打开的文件,Position 为要开始读取的文件中的字节位置。
如果省略 Position,请使用文件的当前位置或当前数据记录。
Variable:要读取的变量的名称。除对象变量外,可以使用任何变量类型。
Sub ExampleRandomAccess
Dim iNumber As Integer
Dim sText As Variant REM Must be a variant
Dim aFile As String
aFile = "c:\data.txt"
iNumber = Freefile
Open aFile For Random As #iNumber Len=32
Seek #iNumber,1 REM Position at beginning
Put #iNumber,, "This is the first line of text" REM Fill line with text
Put #iNumber,, "This is the second line of text"
Put #iNumber,, "This is the third line of text"
Seek #iNumber,2
Get #iNumber,,sText
Print sText
Close #iNumber
iNumber = Freefile
Open aFile For Random As #iNumber Len=32
Get #iNumber,2,sText
Put #iNumber,,"This is a new text"
Get #iNumber,1,sText
Get #iNumber,2,sText
Put #iNumber,20,"This is the text in record 20"
Print Lof(#iNumber)
Close #iNumber
end sub