Time

Discuss PocketC for Palm OS (including Desktop Edition)

Postby pradip on Wed Nov 30, 2005 12:59 am

Hello, i'm newbie in programming.
Does anyone can tell me how to make time in 'real time mode'. I ever use stupid code like this:

main ()
{
int a, b; string s;
graph_on();
title("real time");
text(3, 20, "Time:");

textattr(1,1,0);
do
{
event(10); a=time(2);
s=strright(a,2);
text(25, 20, "\t\t" + time(1) + ":"+s+"");
}
while(b!=5);
}

anyway, it works as a stand alone application. But it doesn't if the code merged into an application. Does anyone tell me a better solution?
pradip
 
Posts: 7
Joined: Wed Nov 30, 2005 12:42 am
Location: Indonesia

Postby dewey on Sun Dec 04, 2005 3:59 pm

Can you be more specific? What doesn't work?
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby pradip on Mon Dec 05, 2005 1:40 am

I mean, when i use CControl to add some button in my program, and i insert my code (time) in somewhere, the button doesn't works.
Because it's seems the code of button (Ccontol) never be executed. I have no idea how to solve it.
pradip
 
Posts: 7
Joined: Wed Nov 30, 2005 12:42 am
Location: Indonesia

Postby dewey on Tue Dec 13, 2005 8:07 am

You would need to share the code that doesn't work, otherwise no one will be able to help you.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby pradip on Thu Dec 15, 2005 1:24 am

This is my code:

// The real time main (CEditor)

include "Ccontrols.c"

/$The real time controls (CEditor)
Chandle about;

initcontrols()
{
about=Cbutton(3,146,33,12,1,4);
}

initcontents()
{
Csetcontent(about,"About");
}

inititems(){
}

drawcontrols()
{
Cdraw(about);
}

/$ The real time methods (CEditor)
on_about()
{
alert("Example.\n\nReal time.");
}

messageloop()
{
int e;
while(1)
{
e=event(1);
if(Cevent(about,e)) on_about();
}
}

realtime ()
{
int a, b; string s;
text(3, 20, "Time:");
textattr(1,1,0);
do
{
event(10); a=time(2);
s=strright(a,2);
text(25, 20, "\t\t" + time(1) + ":"+s+"");
}
while(b!=5);
}


main()
{
graph_on();
title("The real time");
Cinit();
realtime();
initcontrols();
initcontents();
inititems();
drawcontrols();
messageloop();
}

If compiled, this program does't work properly.
pradip
 
Posts: 7
Joined: Wed Nov 30, 2005 12:42 am
Location: Indonesia

Postby dewey on Thu Dec 15, 2005 3:13 pm

The problem is that you have two event loops: messageloop() and realtime(), and realtime() never exits since b will never equal 5. You should only be using messageloop() if you want your CControls UI to function.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby pradip on Fri Dec 16, 2005 1:04 am

I see. I need learn more i think
pradip
 
Posts: 7
Joined: Wed Nov 30, 2005 12:42 am
Location: Indonesia


Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 2 guests

cron