Announcement

Collapse
No announcement yet.

DoEvents

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DoEvents

    Is there a way to perform a DoEvents call in PB? I am using PB2.0
    and I need to return control to the system while a routine is running.


    ------------------
    Explorations v3.0 RPG Development System
    http://www.explore-rpg.com
    Explorations v9.10 RPG Development System
    http://www.explore-rpg.com

  • #2
    You should use the search engine of this Forum.
    You'll find a lot of examples for DoEvents

    ------------------
    E-Mail (home): mailto:[email protected][email protected]</A>
    E-Mail (work): mailto:sv[email protected][email protected]</A>

    Comment


    • #3
      If you're thinking of a VB-style DoEvents, that's not something you can mimic
      readily. VB's design is inside-out with respect to what VB is actually doing.
      Essentially, a VB DoEvents is releasing control back to VB's hidden message
      loop. In PowerBASIC, you have direct control over the message loop (if any),
      so there is no point in a "DoEvents" as such. You just need to break up your
      processing during the message loop so as to avoid taking up too much time in
      any one cycle.

      If your program does not include a message loop, perhaps the Windows API call
      Yield is what you want. See your WINAPI.INC include file.

      I suspect Sven has 32-bit PB/DLL in mind, which is a somewhat different animal.


      ------------------
      Tom Hanlin
      PowerBASIC Staff

      Comment


      • #4
        >I suspect Sven has 32-bit PB/DLL in mind, which is a somewhat different animal.

        Oh, didn't see the "PB 2.0".


        ------------------
        E-Mail (home): mailto:[email protected][email protected]</A>
        E-Mail (work): mailto:[email protected][email protected]</A>

        Comment


        • #5
          Code:
          SUB DoEvents
              STATIC Msg AS tagMsg
              IF PeekMessage(Msg, %NULL, 0, 0, %PM_REMOVE) THEN
                  TranslateMessage Msg
                  DispatchMessage Msg
              END IF
          END SUB
          One of the many snippets in my pbfuncs directory , not sure who wrote that one though


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

          Comment


          • #6
            Would a simple SLEEP 0 perform the trick?

            ------------------
            Thanks,

            John Kovacich
            Thanks,

            John Kovacich
            Ivory Tower Software

            Comment


            • #7
              Wayne, doing a bare message loop in a SUB like that can have assorted
              undesireable side-effects -- don't, unless you're sure you know what
              you're up to! I'd use LOCAL instead of STATIC there, BTW.

              John, good idea, but SLEEP is only available in the 32-bit world.

              ------------------
              Tom Hanlin
              PowerBASIC Staff

              Comment

              Working...
              X