Put# Statement
Escreve um registo para um ficheiro relativo, ou uma sequência de bytes para um ficheiro binário.
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.
Para ficheiros binários (acesso binário), a posição do byte no ficheiro onde pretende começar a escrever.
variable: Name of the variable that you want to write to the file.
Nota para ficheiros relativos. Se o conteúdo desta variável não corresponder ao comprimento do registo especificado na cláusula Len da instrução Abrir, o espaço entre o final do registo recente e o próximo registo é preenchido por dados existentes do ficheiro para o qual está a escrever.
Nota para ficheiros binários: o conteúdo das variáveis é escrito na posição especificada e o apontador de ficheiros é inserido diretamente depois do último byte. Não é deixado qualquer espaço entre os registos.
Sub ExampleRandomAccess
Dim iNumber As Integer
Dim sText As Variant ' Deve ser uma variante
Dim aFile As String
aFile = "C:\Users\ThisUser\data.txt"
iNumber = Freefile
Open aFile For Random As #iNumber Len=32
Seek #iNumber,1 ' Posição no inicio
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