You are here: Development Standards > OSAS Standards > Using String Templates > File Access

# File Access

When you read and write to a file, use the READ RECORD and WRITE RECORD statements.

`0010 LET KEY$=“ACE001”`
`0020 READ RECORD(FILE[1],KEY=KEY$,DOM=0030,ERR=GENERROR)ARCU$; GOTO 0040`
`0030 LET O7=8; GOSUB GENERROR; GOTO READ_NEXT`
`0040 LET ARCU.BALANCE=NEW_BALANCE`
`0050 LET ARCU$=FIELD(ARCU$)`
`0060 WRITE RECORD(FILE[1])ARCU$`

Here is an explanation of the code:

0020 reads the record from FILE[1] into ARCU$ template

0040 sets up a new balance in ARCU.BALANCE

0050 clears extra data from the end of the ARCU$ template

0060 writes the record

Line 50 is required before you write any record into OSAS files. As the READ RECORD statement reads the record into the ARCU$ template, BBx pads the end of the templates with nulls ($00$) up to the length of the record from the data file. In this case, the template would be padded with enough nulls to bring the template up to 1024 bytes (the record length of the file). The FIELD clause on a template will clear the trailing nulls from the end of the template.