Put# Statement
Zapisuje rekord do pliku względnego lub sekwencję bajtów do pliku binarnego.
Use Print# statement to print data to a sequential text file. Use Write# statement to write data to a sequential text file with delimiting characters.

Put [#]fileNum, [recordNum|filePos], variable
fileNum: Any integer expression that defines the file that you want to write to.
recordNum, filePos: For relative files (random access files), the number of the record that you want to write.
W przypadku plików binarnych (otwartych w trybie Binary) pozycja stanowi pozycję bajtu w pliku, od której należy rozpocząć zapis.
variable: Name of the variable that you want to write to the file.
Uwaga dotycząca plików względnych: Jeśli zawartość tej zmiennej ma inną długość niż długość rekordu określona w klauzuli Len instrukcji Open, miejsce pomiędzy końcem aktualnie dopisanego rekordu i następnym rekordem pozostaje wypełnione danymi już istniejącym w tym pliku.
Uwaga dotycząca plików binarnych: Zawartość zmiennej jest zapisywana w określonej pozycji, a wskaźnik pliku jest ustawiany bezpośrednio za ostatnim zapisanym bajtem. Pomiędzy rekordami nie jest pozostawiane wolne miejsce.
Sub ExampleRandomAccess
Dim iNumber As Integer
Dim sText As Variant ' Musi być typu variant
Dim aFile As String
aFile = "C:\Users\ThisUser\data.txt"
iNumber = Freefile
Open aFile For Random As #iNumber Len=32
Seek #iNumber,1 ' Pozycja rozpoczęcia
Put #iNumber, , "This is the first line of text" ' 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
Sub ExampleRandomAccess
Dim iNumber As Integer
Dim sText As Variant ' Must be a variant
Dim aFile As String
aFile = "~/data.txt"
iNumber = Freefile
Open aFile For Random As #iNumber Len=32
Seek #iNumber,1 ' Position at beginning
Put #iNumber, , "This is the first line of text" ' 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