Results 1 to 8 of 8

Thread: Converting cross-platform C++ timer code to pascal...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Code:
    gettimeofday
    Will not work with FreePascal. You should use fpGetTimeOfDay instead, and unit Unix.

  2. #2
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    you may want to wrap it up in a class or put the timer vars in a record that you can pass to the functions to allow multiple timers.
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  3. #3
    @Andru: thanks mate, that sort of information was what I was hoping for
    @philbermon: I think I will go the record route, thanks for the idea!

    cheers,
    Paul

  4. #4
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    The X window system I am working on has a 3 stage timer built into the TApplication. it is a stak based timer adding timers is as easy as
    Code:
    Application.AddMsTask('OnTimer',Window,@OnTimer,10);
    Application.AddSecTask('OnTimer',Window,@OnTimer,13);
    Application.AddMinTask('OnTimer',Window,@OnTimer,22);
    the Ontimer is the event handling code and if it return's a True the event will remove itself.
    to test it I opened 12 windows with a rotationing object in each. it seems to work very well as long as the load can be handled. I've only tested the AddMsTask so far but I see no reason why the others shouldn't work as expected. My system is built around a very custom linked list design. that allows for managing many lists from a single object. so it made since to build the timer functions into the application rather then creating a bunch of timer objects. this way all events are processed in a single loop including all of the X events.

  5. #5
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Turns out that Andru's right as always. Seems like his soltuion works for me on a Ubuntu 10.10 x64 Box with fpc 2.4.0 (ppcx64) if anyone is after the technicalities. Good find though.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  6. #6
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    I believe the correct unit is SysUtils as this has crossplatform support.
    http://www.freepascal.org/docs-html/...ils/index.html

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •