Loading ...
Sorry, an error occurred while loading the content.

RE: [libertybasic] menu halts program

Expand Messages
  • Stefan Pendl
    ... Instead of using a loop you can use a TIMER to update the graph. The basic structure would be: ... [StartTimerLoop] first turn timer off, so we can do
    Message 1 of 4 , May 1, 2010
    • 0 Attachment
      >
      > Hi,
      >
      > This is the second time I've tried to post this query. It
      > didn't seem to appear, so apologies if it does appear twice.
      >
      > I have a continuous graphing program which has a a menu bar.
      > The main loop of the program is something like:
      >
      > Do
      > Scan
      > Loop until 1=0
      >
      > When the menu is accessed (or in fact, any windows dialogue
      > box like FILEDIALOG is brought up) the program halts the loop
      > until the menu is closed again, then the loop continues.
      >
      > Has anyone else experienced this? Is this a limitation of
      > LB, or is there some workaround?
      >
      >
      > Many thanks,
      > Ross
      >

      Instead of using a loop you can use a TIMER to update the graph.

      The basic structure would be:

      '...

      [StartTimerLoop]
      ' first turn timer off, so we can do our work without getting interrupted
      TIMER 0

      '...

      TIMER 100, [StartTimerLoop]

      '...

      The advantage is, that you can turn off the constant update of the graph from anywhere in your program by issuing a "TIMER 0"
      command.

      To have the update of the graph being fully independent from the GUI user interaction, one would have to create a separate thread
      for the graph update procedure, but this currently not possible with LB.

      ---
      Stefan Pendl

      Liberty BASIC Assist 4.03 ........ http://www.libertybasic.com/assist.html
      Liberty BASIC 4.04 RC2 ........... http://www.libertybasic.com/lb404setup.exe

      Books at http://www.lulu.com/ and http://www.amazon.com/
      Alyce Watson ... APIs for Liberty BASIC
      Carl Gundel .... Beginning Programming with Liberty BASIC

      Windows 7 Home Premium 64-bit RTM
      AMD Turion X2 RM-70 2GHz, 4GB RAM
    • ross_harper512
      Hi Stefan Thanks for the reply. I don t know what you mean by a separate thread . Could you clarify? Ross
      Message 2 of 4 , May 1, 2010
      • 0 Attachment
        Hi Stefan

        Thanks for the reply. I don't know what you mean by "a separate thread". Could you clarify?

        Ross

        --- In libertybasic@yahoogroups.com, "Stefan Pendl" <pendl2megabit@...> wrote:
        >
        > >
        > > Hi,
        > >
        > > This is the second time I've tried to post this query. It
        > > didn't seem to appear, so apologies if it does appear twice.
        > >
        > > I have a continuous graphing program which has a a menu bar.
        > > The main loop of the program is something like:
        > >
        > > Do
        > > Scan
        > > Loop until 1=0
        > >
        > > When the menu is accessed (or in fact, any windows dialogue
        > > box like FILEDIALOG is brought up) the program halts the loop
        > > until the menu is closed again, then the loop continues.
        > >
        > > Has anyone else experienced this? Is this a limitation of
        > > LB, or is there some workaround?
        > >
        > >
        > > Many thanks,
        > > Ross
        > >
        >
        > Instead of using a loop you can use a TIMER to update the graph.
        >
        > The basic structure would be:
        >
        > '...
        >
        > [StartTimerLoop]
        > ' first turn timer off, so we can do our work without getting interrupted
        > TIMER 0
        >
        > '...
        >
        > TIMER 100, [StartTimerLoop]
        >
        > '...
        >
        > The advantage is, that you can turn off the constant update of the graph from anywhere in your program by issuing a "TIMER 0"
        > command.
        >
        > To have the update of the graph being fully independent from the GUI user interaction, one would have to create a separate thread
        > for the graph update procedure, but this currently not possible with LB.
        >
        > ---
        > Stefan Pendl
        >
        > Liberty BASIC Assist 4.03 ........ http://www.libertybasic.com/assist.html
        > Liberty BASIC 4.04 RC2 ........... http://www.libertybasic.com/lb404setup.exe
        >
        > Books at http://www.lulu.com/ and http://www.amazon.com/
        > Alyce Watson ... APIs for Liberty BASIC
        > Carl Gundel .... Beginning Programming with Liberty BASIC
        >
        > Windows 7 Home Premium 64-bit RTM
        > AMD Turion X2 RM-70 2GHz, 4GB RAM
        >
      • Stefan Pendl
        ... When you start a program, Windows will launch it in a process. This process is doing his work in a thread, which is called the main-thread. Now, if you
        Message 3 of 4 , May 1, 2010
        • 0 Attachment
          > > >
          > > > I have a continuous graphing program which has a a menu bar.
          > > > The main loop of the program is something like:
          > > >
          > > > Do
          > > > Scan
          > > > Loop until 1=0
          > > >
          > > > When the menu is accessed (or in fact, any windows dialogue
          > > > box like FILEDIALOG is brought up) the program halts the loop
          > > > until the menu is closed again, then the loop continues.
          > > >
          > >
          > > Instead of using a loop you can use a TIMER to update the graph.
          > >

          ---snip

          > >
          > > To have the update of the graph being fully independent
          > from the GUI user interaction, one would have to create a
          > separate thread
          > > for the graph update procedure, but this currently not
          > possible with LB.
          > >
          >
          > Hi Stefan
          >
          > Thanks for the reply. I don't know what you mean by "a
          > separate thread". Could you clarify?
          >
          > Ross
          >

          When you start a program, Windows will launch it in a process.
          This process is doing his work in a thread, which is called the main-thread.

          Now, if you need to do some work concurrently you would create a child thread, which will then do the separate work.
          This is as simple as multi-threading can be described.

          The problem is, that developing a multi-threaded application, which is thread-safe, is a challenging task.

          ---

          You could think about it in a different way:

          You run your program and it launches another TKN, which receives the handle to the graphics box, where the graph should be
          displayed.
          The second program draws the graph, sends the image to the graphics box and notifies the main program of the change.

          ---
          Stefan Pendl

          Liberty BASIC Assist 4.03 ........ http://www.libertybasic.com/assist.html
          Liberty BASIC 4.04 RC2 ........... http://www.libertybasic.com/lb404setup.exe

          Books at http://www.lulu.com/ and http://www.amazon.com/
          Alyce Watson ... APIs for Liberty BASIC
          Carl Gundel .... Beginning Programming with Liberty BASIC

          Windows 7 Home Premium 64-bit RTM
          AMD Turion X2 RM-70 2GHz, 4GB RAM
        Your message has been successfully submitted and would be delivered to recipients shortly.