In the first place I would like to thank you because you helped me a lot,
however, I am still having a problem while trying to create the record. The
record consists of the following structure:
typedef struct
{
char * Nombre;
char * NickName;
} JugadorType;
and I use the following function to store the data.
void GuardarDatosJugador ()
{
FieldPtr fieldP;
MemHandle recordHandle;
UInt16 index = dmMaxRecordIndex;
JugadorType Jugador, * JugadorPtr;
UInt16 size;
fieldP = GetObjectPtr ( NombresNombreField );
Jugador.Nombre = ( char * ) MemPtrNew ( StrLen ( fieldP->text ) + 1 );
StrCopy ( Jugador.Nombre, fieldP->text );
fieldP = GetObjectPtr ( NombresNicknameField );
Jugador.NickName = ( char * ) MemPtrNew ( StrLen ( fieldP->text ) + 1 );
StrCopy ( Jugador.NickName, fieldP->text );
size = StrLen ( Jugador.NickName ) + StrLen ( Jugador.Nombre ) + 2;
recordHandle = DmNewRecord ( JugadoresDB, &index , size );
JugadorPtr = MemHandleLock ( recordHandle );
// here is where the pose tells me that a fatal exeption ocurred... what is
wrong?
DmWrite ( recordHandle, 0, Jugador.Nombre, size );
MemHandleUnlock ( recordHandle );
DmReleaseRecord ( JugadoresDB, index, true );
}
Thanks a lot for any help...
Nicolas
-----Mensaje original-----
De: Jeff Wheeler <[EMAIL PROTECTED]>
Grupos de noticias: palm-dev-forum
Para: Palm Developer Forum <[EMAIL PROTECTED]>
Fecha: Martes, 24 de Abril de 2001 10:34 a.m.
Asunto: Re: DmNewRecord
>> Hi to all... I have been having a little trouble while trying to create a
>> new record in a database... could someone be so polite of posting a basic
>> code in order to create it, or at least which functions I should use to
do
>> so.
>
>There's a couple of ways to do this. Here's one:
>
>1. Figure out how many bytes are in the record.
>
>2. Use DmNewRecord() to allocate a record with that many bytes. Set the
>index to dmMaxRecordIndex to make the record show up at the end of the
>records in the database. You'll get back both the handle of the new
record,
>and the index of the record in the database.
>
>3. Use MemHandleLock() to lock the database record memory.
>
>4. Use DmWrite() to write data into the record.
>
>5. Use MemHandleUnlock() to unlock the memory handle.
>
>6. Use DmReleaseRecord() to release the record in the database, and mark it
>as "dirty".
>
>For more assistance:
>
>1. Look at the source code for the built-in applications, such as
>Address.mcp.
>
>2. Buy a Palm OS programming book (there's a recent thread here about book
>recommendations).
>
>3. Refer to the SDK for usage of specific functions.
>
>4. Search the knowledge base.
>
>Hope this introduction helps.
>
>Jeff
>
>
>
>
>
>
>--
>For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/