Conteníu

# Put# Statement

Escribe un rexistru nun ficheru relativu o una secuencia de bytes nun ficheru binariu.

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.

### Syntax:

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

### Parameters:

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.

N'ficheros binarios (accesu binariu), la posición del byte del ficheru en que se deseye empezar a escribir.

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

Nota p'ficheros relativos: Si'l conteníu d'esta variable nun coincide col llargor del rexistru que s'especifica na clausa Len de la instrucción Open, l'espaciu ente'l final del rexistru escritu apocayá y el siguiente rellenar colos datos esistentes del ficheru al que ta escribiendo.

Nota p'ficheros binarios: El conteníu de les variables escribir na posición especificada y el punteru del ficheru inxertar direutamente dempués del postreru byte. Nun se dexa espaciu ente los rexistros.

### Example:

      Sub ExampleRandomAccess
          Dim iNumber As Integer
          Dim sText As Variant ' Tien De ser una variante
          Dim aFile As String
          aFile = "C:\Users\ThisUser\data.txt"
          iNumber = Freefile
          Open aFile For Random As #iNumber Len=32
          Seek #iNumber,1 ' Posición al entamu
          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 ' Tien De ser una variante
          Dim aFile As String
          aFile = "~/data.txt"
          iNumber = Freefile
          Open aFile For Random As #iNumber Len=32
          Seek #iNumber,1 ' Posición al entamu
          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

Temes rellacionaos

Close Statement

Get Statement

Open Statement