timegap between execution of functions

This is a discussion on timegap between execution of functions within the C Programming forums, part of the General Programming Boards category; hi, i want my code to execute a set of functions keeping a certain time gap between the executions. how ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    5

    Exclamation timegap between execution of functions

    hi,

    i want my code to execute a set of functions keeping a certain time gap between the executions. how do i do that?

    thanks

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    what compiler and operating systems. *nix uses sleep(int seconds) and MS-Windows uses Sleep(long milliseconds) (note spelling differences). MS-DOS Borland compilers like TurboC uses delay(). I don't know about other operating systems.

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    5

    os is unix

    actually i want to disply an object moving down on a xwindow. so i used the following method. but now i want to display an arbitrary numer of such objects dropping at different times, different different x cooordinates.
    Code:
    while(j<height_window)
    	{
    		XSetForeground(disp,gc,BlackPixel(disp,DefaultScreen(disp)));
    		XFillArc(disp, win, gc, 300-(30/2), j-(30/2), 30, 30, 0, 180*64);
    		XFlush(disp);
    		usleep(20000);
    		c1++;
    		if(c1>20)
    		{			
    		j=j+10;
    		XSetForeground(disp,gc,WhitePixel(disp,DefaultScreen(disp)));
    		XFillArc(disp, win, gc, 300-(30/2), j-10-(30/2), 30, 30, 0, 180*64);
    	}
    so this is the the whole picture

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    5

    oops coorection

    the
    part
    Code:
    if(c1>20)
    {
    shouldn't be thr.

  5. #5
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Quote Originally Posted by sourdon
    the
    part
    Code:
    if(c1>20)
    {
    shouldn't be thr.
    You could have just pressed the <Edit> button and removed it.

    I suppose you might have to implement threads to do that where each object type is in its own thread.

  6. #6
    Registered User
    Join Date
    Sep 2005
    Posts
    5
    how do i do that in c

  7. #7
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    depends on the os. you posted usleep() so I think you are using some version of *nix.

    here is a tutorial

  8. #8
    Registered User
    Join Date
    Sep 2005
    Posts
    5
    thanx man

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  2. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 02:41 PM
  3. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 06:39 AM
  4. Inline functions and inheritance
    By hpy_gilmore8 in forum C++ Programming
    Replies: 3
    Last Post: 01-14-2004, 06:46 PM
  5. functions - please help!!!!
    By linkies in forum C Programming
    Replies: 1
    Last Post: 08-21-2002, 08:53 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21