#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    17
    Rep Power
    0

    Question Pause Syntax in C (Palm programming)


    i'm modifing an app in palm, but i need syntax for command what would pause the script for 1second.
    Scirpiting language is C

    Have searched fo sleep, wait, pause but havent found anything realting to these words in manual
  2. #2
  3. No Profile Picture
    status unknown
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    262
    Rep Power
    11
    If you don't have anything predefined, you can easily write your own pause routine using the functions in <time.h>. In fact, this has been done many times before so I'd be surprised if a quick search didn't throw up some examples.
  4. #3
  5. Cast down
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    321
    Rep Power
    11
    Some pseudo (sp) code using GetTickCount (returns uptime in milliseconds):

    If TheCurrentUptime is less than or equal to olduptime + 1000 then
    do whatever, because 1000 passed
    else
    olduptime = TheCurrentUptime, keep checking in the if statement..

    ----------------

    if uptime is 5000
    it checks to see if the time is now 6000, if it isn't, then it just keeps rechecking, and when it is 6000 (1 second, or 1000 milliseconds passed), it will continue

    [update]
    Ok, that top part wasn't explained so well, imo, here:
    Code:
    #include <windows.h>
    #include <iostream.h>
    void main()
    {
    	long TEMP = 0;
    	long LASTTIME=0;
    	long DELAY = 1000;
    	
    	do
    	{
    		TEMP = GetTickCount();
    		if (TEMP >= LASTTIME + DELAY)
    		{
    			cout << "Tick TocK" << endl;
    			LASTTIME = TEMP;
    		}
    	}while(1);
    }
    [/update]
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    17
    Rep Power
    0
    SysTaskDelay(); is the easyest function
    another function will output system ticks per second..so using those 2 i can make any delay i want+processor is being put on standby(doesn't serve any use for me allthow - on second battery saving is not much :))..so it will take less battery the using this function
    only two lines and lot simpler


    thnx anyway

IMN logo majestic logo threadwatch logo seochat tools logo