See the programming example for BSAVE.