# File lib/kirbybase.rb, line 1130
    def insert_record(table, rec)
        with_write_locked_table(table) do |fptr|
            # Auto-increment the record number field.

            rec_no = incr_rec_no_ctr(table, fptr)

            # Insert the newly created record number value at the beginning

            # of the field values.

            rec[0] = rec_no

            fptr.seek(0, IO::SEEK_END)
            fpos = fptr.tell

            write_record(table, fptr, 'end', rec.join('|'))

            add_to_indexes(table, rec, fpos)

            # Return the record number of the newly created record.

            return rec_no
        end
    end