Technical Information

Application Development Manual | Writing to data files

Writing to data files


Write a record to a data file.


Detailed Description

The PUT statement builds a record from the current values of the field variables defined in the FIELD statement and writes it to the specified data file.

Set fileno to the value specified when opening the data file.

recordno specifies, as a record number, the write position. If this parameter is omitted, the BHT uses the current maximum record number +1, adding the record to the end of the data file.

Note that always convert numerical data to string data with the STR$ function before assigning it to a field variable.


Write field data (3, 10, 4901234567890) to record #3.

  private SNO%
private QTY%
private SNO$
private QTY$
private BARDATA$
open "TESTDATA.DAT" as #1                       ' open data file
field #1, 3 as SNO$, 5 as QTY$, 13 as BARDATA$  ' define fields
SNO% = 3                                        ' field 1 data
SNO$ = STR$(SNO%)                               ' convert numerical data to string
QTY% = 10                                       ' field 2 data
QTY$ = STR$(QTY%)                               ' convert numerical data to string
BARDATA$ = "4901234567890"                      ' assign data to field 3
put #1,3                                        ' write to data file

Contact us