/*--------------------------------------------------------------------
 * FICHERO:  BdtEscRe.c
 * OBJETIVO: Definir la funcin Bdt_EscribeRegistro()
 * AUTOR:    Pedro Reina
 * FECHA:    J.1.6.1995
 *------------------------------------------------------------------*/

/*--------------------------------------------------------------------
 * Ficheros de cabecera
 *------------------------------------------------------------------*/

#include "BaseDato.h"

/*--------------------------------------------------------------------
 * Definicin de funciones
 *------------------------------------------------------------------*/

/*--------------------------------------------------------------Olimpo
 * FUNCION:  Bdt_EscribeRegistro()
 * OBJETIVO: Escribir un registro desde memoria al fichero
 * ENTRADAS: La base de datos y el nmero de registro
 * SALIDAS:  Lgica indicando si el registro se ha escrito.
 * NOTA:     Los registros se cuentan a partir de 0
 * EJEMPLO:  Bdt_EscribeRegistro (Agenda,1)
 *------------------------------------------------------------------*/
logico Bdt_EscribeRegistro (Base, Numero)
basedato Base;
entero   Numero;
  {
  logico Respuesta = NO;

  if ( Numero >= 0 && Numero < Bdt_TotalRegistro(Base) &&
       Bdt_ModoApertura(Base) == BDT_ACTUALIZACION )
    {
    Fch_Coloca (Bdt_Fichero(Base), Bdt_ComienzoRegistro(Base) +
                                   Bdt_LongitudRegistro(Base) * Numero );
    if ( Fch_EscribeOcteto (Bdt_Fichero(Base), Bdt_InfoActual(Base),
                            Bdt_LongitudRegistro(Base)) )
      {
      Respuesta = SI;
      Bdt_PonActual (Base,Numero);
      Bdt_PonModificado (Base,SI);
      }
    }

  return ( Respuesta );
  }