--- Mark Kenny <[EMAIL PROTECTED]> wrote:
> Thanks for that i understand you but where exactly 
> would i do this line in my view fn, or db???  
> sorry but i'm just getting into this stuff now
> thanks 

I had to go back and read your original post to figure out what you're
asking... You want to 'insert "Type" into a field to display it'.

1. Open your database.
2. Use DmQueryRecord (or similar method) to get a handle to a record.
3. Lock the handle to get a pointer to the record and typecast that
pointer to ModuleType.
3. Then you have 3 pieces of data:
  yourPointer->day      - a number, 0 thru 6
  yourPointer->errands  - a string
  yourPointer->Type     - an enum (stored as some kind of integer)
4. Display the above three in one or more fields on a form
  a) convert the data to a string (here you may use the method I
previously gave)
  b) call a function to put that string in a field

Here are two functions that will help with the general case of putting
a string in a field:

// Set text in a field, given a fieldID and a handle to the text
static FieldPtr SetFieldTextFromHandle( UInt16 fieldID, MemHandle txtH
)
{
  MemHandle oldTxtH;
  FieldPtr  fldP;
  FormPtr   frmP = FrmGetActiveForm();

  // get the field and a handle to its text
  fldP = FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, fieldID ) );
  ErrNonFatalDisplayIf( !fldP, "missing field" );
  oldTxtH = FldGetTextHandle( fldP );

  // set field to new text
  FldSetTextHandle( fldP, txtH );
  FldDrawField( fldP );

  // free old MemHandle
  if ( oldTxtH ) MemHandleFree( oldTxtH );

  return fldP;  
}

// Sets text in a field, given a fieldID and a pointer to a string
static FieldPtr SetFieldTextFromStr( UInt16 fieldID, Char *strP )
{
  MemHandle txtH;

  txtH = MemHandleNew( StrLen( strP ) + 1 );
  if ( !txtH )
    return NULL;
  StrCopy( MemHandleLock( txtH ), strP );
  MemHandleUnlock( txtH );
  return SetFieldTextFromHandle( fieldID, txtH );
}


__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
http://movies.yahoo.com/

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to