# File lib/kirbybase.rb, line 2116
    def insert(*data, &insert_proc)
        raise 'Cannot specify both a hash/array/struct and a ' + \
         'proc for method #insert!' unless data.empty? or insert_proc.nil?

        raise 'Must specify either hash/array/struct or insert ' + \
         'proc for method #insert!' if data.empty? and insert_proc.nil?

        # Update the header variables.

        update_header_vars

        # Convert input, which could be a proc, an array, a hash, or a

        # Struct into a common format (i.e. hash).

        if data.empty?
            input_rec = convert_input_data(insert_proc)
        else
            input_rec = convert_input_data(data)
        end

        # Check the field values to make sure they are proper types.

        validate_input(input_rec)

        input_rec = Struct.new(*field_names).new(*field_names.zip(
         @field_defaults).collect do |fn, fd|
            if input_rec.has_key?(fn)
                input_rec[fn]
            else
                fd
            end
        end)

        check_required_fields(input_rec)

        check_against_input_for_specials(input_rec)

        new_recno = @db.engine.insert_record(self, @field_names.zip(
         @field_types).collect do |fn, ft|
            convert_to_encoded_string(ft, input_rec[fn])
        end)

        # If there are any associated memo/blob fields, save their values.

        input_rec.each { |r| r.write_to_file if r.is_a?(KBMemo) } if \
         @field_types.include?(:Memo)
        input_rec.each { |r| r.write_to_file if r.is_a?(KBBlob) } if \
         @field_types.include?(:Blob)
                        
        return new_recno
    end