Put# Statement

Göreceli dosyaya bir kayıt veya ikilik dosyaya bir bayt dizisi yazar.

tip

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.


Sözdizimi:

Put Statement diagram

Put [#]fileNum, [recordNum|filePos], variable

Parametreler:

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.

İkilik dosyalar için (ikilik erişim), yazmaya başlayacağınız baytın dosyadaki konumu.

variable: Name of the variable that you want to write to the file.

Göreceli dosyalar için not: Eğer bu değişkenin içeriği deyiminin Len cümleciğiyle belirtilen kayıt uzunluğu ile örtüşmezse, yeni girilen kayıt ile sonraki kayır arasındaki boşluk yazdığınız dosyadan veriler ile doldurulur.

İkilik dosyalar için not: Belirtilen pozisyona yazılan değişkenlerin içeriği ve dosya göstergeci son bayttan hemen sonra eklenir. Kayıtlar arasında boşluk bırakılmaz.

Örnek:

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

Lütfen bizi destekleyin!