Put Statement
Zapíše záznam do relatívneho súboru alebo sekvencie do bajtov binárneho súboru.
See also: Get statement
Syntax:
Put [#] FileNumber As Integer, [position], Variable
Paremetre:
FileNumber: Any integer expression that defines the file that you want to write to.
Position: For relative files (random access files), the number of the record that you want to write.
Pre binárne súbory (binárny prístup) určuje pozíciu bajtu, kde má začať zapisovať.
Variable: Name of the variable that you want to write to the file.
Note for relative files: If the contents of this variable does not match the length of the record that is specified in the Len clause of the Open statement, the space between the end of the newly written record and the next record is padded with existing data from the file that you are writing to.
Note for binary files: The contents of the variables are written to the specified position, and the file pointer is inserted directly after the last byte. No space is left between the records.
Príklad:
Sub ExampleRandomAccess
Dim iNumber As Integer
Dim sText As Variant ' Musí byť variant
Dim aFile As String
aFile = "c:\data.txt"
iNumber = Freefile
Open aFile For Random As #iNumber Len=32
Seek #iNumber,1 ' Position To start writing
Put #iNumber,, "This is the first line of text" ' Fill line with text
Print #iNumber, "Toto je riadok textu."
Print #iNumber, "Toto je riadok textu."
Seek #iNumber,2
Get #iNumber,,sText
Print sText
Close #iNumber
iNumber = Freefile
Open aFile For Random As #iNumber Len=32
Get #iNumber,2,sText
Print #iNumber, "Toto je riadok textu."
Get #iNumber,1,sText
Get #iNumber,2,sText
Put #iNumber,20,"Toto je text v zázname 20"
Print Lof(#iNumber)
Close #iNumber
End Sub