Smart Cards and the Open Terminal Architecture
By Edward K. Conklin
Dr. Dobb's Journal December 1998
: INSERT-RECORD ( S: -- ) ( G: Insert a record before the current ) WRITABLE #RECORD 0 MAX \ From the current record DUP >R AVAILABLE DB-INSERT \ To last record, insert record AVAILABLE 1+ TO AVAILABLE \ Increment available R> TO #RECORD \ Reset current record UPDATE-RECORD \ Save file update ; : DBADDREC ( S: -- ) ( G: Add a record to the end of the database ) KIND ORDERED AND \ Check that file is not ordered DB-INVALID-FUNCTION ?THROW \ Exception AVAILABLE TO #RECORD \ Set record number to end of database INSERT-RECORD \ Insert a new record ;
Example 1: Code for DBADDREC.
Copyright © 1998, Dr. Dobb's Journal