PUT$ writes binary data to a file. The file must be opened in BINARY mode and the SEEK statement must be used to set the next write position in the file.
VBA's PUT reserved word can be used as an alias to BCX's PUT$ statement.
Syntax:PUT$ hFile AS FILE, _ Buffer AS STRING, _ Number_Of_Bytes_To_Put AS INTEGER Parameters: |
DIM A$ * 5000 ' ************************** ' Create a data file ' to explore ' ************************** OPEN "DATA.BIN" FOR BINARY NEW AS FP1 A$ = REPEAT$(500, CHR$(248)) & "Hello" PUT$ FP1, A$, LEN(A$) CLOSE FP1 ' ************************** ' Now lets read it,starting ' in the middle of the file ' reading 6 bytes at byte ' 500 then going back and ' reading 1000 bytes from ' the beginning of the file ' ************************** CLS OPEN "DATA.BIN" FOR BINARY INPUT AS FP1 SEEK FP1, 500 GET$ FP1, A$, 6 PRINT A$ SEEK FP1, 0 GET$ FP1, A$, 1000 PRINT PRINT PRINT A$ CLOSE FP1