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

Re: Refresh Error

Expand Messages
  • rod_bird001
    Shouldn t refresh be used after locate?
    Message 1 of 11 , Feb 4, 2009
    • 0 Attachment
      Shouldn't refresh be used after locate?
    • Sam Wetterlin
      As I mentioned, I stripped down the program, leaving only enough lines to recreate the error. These refreshes don t actually accomplish anything useful in this
      Message 2 of 11 , Feb 4, 2009
      • 0 Attachment
        As I mentioned, I stripped down the program, leaving only enough lines
        to recreate the error. These refreshes don't actually accomplish
        anything useful in this program, but they do illustrate the error.
        Sam W.

        --- In libertybasic@yahoogroups.com, "rod_bird001" <rodbird@...> wrote:
        >
        > Shouldn't refresh be used after locate?
        >
      • Gordon Rahman
        Hello Sam, The error log says that it misses an object to refresh. Use the LOCATE command (function) to move an object. graphH=50 bmpbutton #graph.textColor
        Message 3 of 11 , Feb 4, 2009
        • 0 Attachment
          Hello Sam,

          The error log says that it misses an object to refresh.
          Use the LOCATE command (function) to move an object.

          graphH=50
          bmpbutton #graph.textColor "bmp\blank.bmp",DoColor,LL, 200,10
          graphicbox #graph.col 160,graphH+10, 38,38

          open "Graph Test" for window as #graph
          #graph "refresh" 'this is here to show it causes no error
          wait

          sub DoColor btn$
          #graph.col "locate 40 90 38 38"
          #graph "refresh" 'this will not cause an error anymore
          end sub

          Gordon


          --- In libertybasic@yahoogroups.com, "Sam Wetterlin" <swetterlin@...>
          wrote:
          >
          > I get a very peculiar error trying to refresh a window in LB 4.03. I
          > have stripped my program down to the following:
          > '-----------------------------------------------
          > graphH=50
          > bmpbutton #graph.textColor "bmp\blank.bmp",DoColor,LL, 200,10
          > graphicbox #graph.col 160,graphH+10, 38,38
          >
          >
          > open "Graph Test" for window as #graph
          > print #graph, "refresh" 'this is here to show it causes no
          error
          > wait
          >
          > sub DoColor btn$
          > print #graph, "refresh" 'this (sometimes) causes an error
          > end sub
          > '-----------------------------------------
          >
          > This runs just fine to the wait statement (Note: you need the bmp
          file
          > in your folder in order to be able to run it.) This means that the
          > refresh command just before "wait" is run fine. But if you now click
          > on the bitmap button, it invokes DoColor where the refresh causes an
          > error. I played with various configurations of buttons, etc.
          Sometimes
          > the error says Argument is not a Collection; sometimes it says the
          > index 2 is out of bounds. Sometimes there is no error.
          >
          > If you delete the graphics box, no error occurs. The weird thing is
          > that the refresh command outside the subroutine never causes an
          error.
          > And I did not get an error if I changed the bitmap button to a
          regular
          > button (still invoking DoColor).
          >
          > The error log is quoted below.
          >
          > Sam W.
          >
        • rod_bird001
          I think it is to do with using a variable in the definition of the graphicbox. If you remove that the sub works. The code works anyway if you just use a branch
          Message 4 of 11 , Feb 4, 2009
          • 0 Attachment
            I think it is to do with using a variable in the definition of the
            graphicbox. If you remove that the sub works. The code works anyway if
            you just use a branch so I think it's about the graphH variable not
            getting passed to the sub when it's needed by the refresh command.

            bmpbutton #graph.bmpb "bmp\blank.bmp",DoColor,LL, 200,10
            graphicbox #graph.gb 160,60,38,38


            open "Graph Test" for window as #graph
            wait

            sub DoColor btn$
            print btn$
            print #graph.bmpb, "locate 20 20 38 38"
            print #graph, "refresh"
            end sub
          • rod_bird001
            Actually make graphH global and it works fine.
            Message 5 of 11 , Feb 4, 2009
            • 0 Attachment
              Actually make graphH global and it works fine.
            • Sam Wetterlin
              Good plan. Thanks. Handles are supposed to be automatically global anyway, but I suppose it doesn t hurt to be explicit.
              Message 6 of 11 , Feb 4, 2009
              • 0 Attachment
                Good plan. Thanks. Handles are supposed to be automatically global
                anyway, but I suppose it doesn't hurt to be explicit.

                --- In libertybasic@yahoogroups.com, "rod_bird001" <rodbird@...> wrote:
                >
                > Actually make graphH global and it works fine.
                >
              • Sam Wetterlin
                Actually, my last reply made no sense. I was thinking it was #graph that needed to be global. That s odd that making graphH global would do anything. In
                Message 7 of 11 , Feb 5, 2009
                • 0 Attachment
                  Actually, my last reply made no sense. I was thinking it was #graph
                  that needed to be global. That's odd that making graphH global would
                  do anything.

                  In addition, with subsequent experiments I have determined that in
                  certain ill-defined circumstances (one aspect of which is that the
                  bitmap has been replaced), even the automatic refresh caused by
                  resizing the window will cause a crash when the window tries to
                  refresh a bitmap button, with an error message about the bitmap handle
                  not being valid. So I would say that you should be wary of using
                  bitmap buttons in a resizable window.
                  Sam W.


                  --- In libertybasic@yahoogroups.com, "Sam Wetterlin" <swetterlin@...>
                  wrote:
                  >
                  > Good plan. Thanks. Handles are supposed to be automatically global
                  > anyway, but I suppose it doesn't hurt to be explicit.
                  >
                  > --- In libertybasic@yahoogroups.com, "rod_bird001" <rodbird@> wrote:
                  > >
                  > > Actually make graphH global and it works fine.
                  > >
                  >
                • rod_bird001
                  Perhaps it s that GUI events and subs don t mix well. It certainly wasn t obvious that your sub needed to know graphH. If I m coding for GUI events I keep it
                  Message 8 of 11 , Feb 5, 2009
                  • 0 Attachment
                    Perhaps it's that GUI events and subs don't mix well. It certainly
                    wasn't obvious that your sub needed to know graphH.

                    If I'm coding for GUI events I keep it all in [branch] code blocks and
                    use scan and wait to manage flow. If I use a function it's a short
                    sweet transformation and I simply avoid subs preferring gosub [branch]
                    return. Subs do have their place as folks will be quick to say but for
                    GUI, particularly if your new to GUI and events, I'd stay out of subs
                    unless you are very clear of the need for it.

                    But hey I'm not classicaly trained it's been a sort of organic
                    exploration. I'm sure other folks will have alternative views.
                  Your message has been successfully submitted and would be delivered to recipients shortly.