PUT$ statement

Purpose

Write a string to a file opened in binary mode.

Syntax

PUT$ [#] filenum&, string_expression

Remarks

PUT$ writes the contents of string_expression to file filenum& at the file's current file pointer position.  File filenum& must have been opened in binary mode.

If the file pointer position is at the end of the file, PUT$ appends (adds) string_expression to the file, increasing its length by LEN(string_expression) bytes.  If the file pointer is before the end of the file, PUT$ overwrites existing data with string_expression.  In either case, the file pointer position following a PUT$ is at the end of the just-written string.  You can use SEEK to retrieve or change the file pointer position.

See also

GET, GET$, OPEN, PUT, SEEK functionSEEK statementSETEOF, WRITE#

Example

' Open a binary file and write the alphabet to it

OPEN "SEEK.DTA" FOR BINARY AS #1 BASE = 1

FOR I& = ASC("A") TO ASC("Z")   ' 65 TO 90

  PUT$ #1, CHR$(I&)

NEXT

CLOSE #1