Terry Young wrote:

I want to display the time on a form. I have several questions:
1 - What event (or interrupt) do I look for to update the time
   in the event loop.
2 - Is there a way to set the interval of the event.
3 - This has to be backward compatable to PalmOS 2.0
4 - Does anyone have any sample code I could look at.

Thanks in advance.

Terry



Well it seems I can make it a little easier for you.
I use in one of my Apps a little funktion, that returns the current time
already formatted in a little String:

char* dbaGetTimeStr(char dateString[12], UInt16 which)
{
DateTimeType date;
UInt32 Zeit;
UInt16 len,pos;
char p[10],*cpos;


   Zeit = TimGetSeconds();
   pos=0;

   TimSecondsToDateTime(Zeit,&date);

   MemSet(dateString,StrLen(p),0);

   cpos= StrIToA(p,(date.hour));
 len = StrLen(p);
 len = VNStrCpy(&dateString[pos],p,len);

 MemSet(p,StrLen(p),0);

 pos = pos+len;
 len = VNStrCpy(&dateString[pos],":",(1*sizeof(char)));
 pos = pos+len;

 if(date.minute<10)
 {
     p[0]='0';
     cpos= StrIToA(&p[1],(date.minute));
   }
   else
     cpos= StrIToA(p,(date.minute));
 len = StrLen(p);
 len = VNStrCpy(&dateString[pos],p,len);

 if(which)
   {
     MemSet(p,StrLen(p),0);

     pos = pos+len;
     len = VNStrCpy(&dateString[pos],":",(1*sizeof(char)));
     pos = pos+len;

if(date.second<10)
{
p[0]='0';
cpos= StrIToA(&p[1],(date.second));
}
else
cpos= StrIToA(p,(date.second));
len = StrLen(p);
len = VNStrCpy(&dateString[pos],p,len);
pos=pos+len; } return (char*)dateString;


}

and as Brandon said you just have to say in your eventloop
EvtGetEvent(&event, ticks);

where ticks is the time you want the app to update your time.
I would suggest 6000 for an update every minute.
You just have to fetch the nilEvent in your eventhandler to call the
function and display the time in a field.

Christian



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

Reply via email to