Instrución Put

Escribe un rexistro nun ficheiro relativo ou unha secuencia de bytes nun ficheiro binario.

See also: Get statement

Sintaxe:


Put [#] NúmeroFicheiro As Integer, [posición], Variábel

Parámetros:

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.

En ficheiros binarios (acceso binario), a posición do byte no ficheiro onde desexa iniciar a escritura.

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.

Nota para ficheiros binarios: O contido das variábeis escríbese na posición especificada, e o apuntador do ficheiro insírese directamente despois do último byte. Non permanece ningún espazo entre os rexistros.

Exemplo:


Sub ExampleRandomAccess
Dim iNumber As Integer
Dim sTexto As Variant REM Debe ser un tipo de variante
Dim aFile As String
    aFile = "c:\data.txt"
    iNumber = Freefile
    Open aFile For Random As #iNumber Len=32
    Seek #iNumero,1 REM Posición para iniciar escritura
    Put #iNumber,, "Esta é a primeira liña do texto" REM Fill line with text
    Put #iNumber,, "Esta é a segunda liña do texto"
    Put #iNumber,, "Esta é a terceira liña do texto"
    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 #iNumero,,"Isto é un novo texto"
    Get #iNumber,1,sText
    Get #iNumber,2,sText
    Put #iNumber,20,"Este é o texto do rexistro 20"
    Print Lof(#iNumber)
    Close #iNumber
End Sub

Precisamos da súa axuda!