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

Error dealing with SCAN

Expand Messages
  • Jack Harvey
    July 30/05 Hi, Can anyone point out the error in the coding below? It prints a set of expanding circles, then pauses for 3 seconds. An error results if
    Message 1 of 2 , Jul 30, 2005
      July 30/05
      Hi,
      Can anyone point out the error in the coding below? It prints a set of
      expanding circles, then pauses for 3 seconds. An error results if
      Restart or Quit is clicked DURING THE PAUSE, just after the circles have
      been drawn. I'm new to LB but have programmed in other languages. I am
      running LB Gold, ver 4.02.

      'Test2.bas, Jack Harvey
      nomainwin
      WindowWidth = DisplayWidth 'use entire screen
      WindowHeight = DisplayHeight
      button #1, "Restart", [restart], UL, 50, 10
      button #1, "Quit", [quit], UL, 50, 40
      open "Exper" for graphics as #1
      print #1, "trapclose [quit]"

      [restart]
      print #1, "down ; fill yellow"
      print #1, "set 200 200"

      'clicking Restart or Quit works ok in the following loop
      for radius = 10 to 100 step .01 scan
      print #1, "circle ";radius
      next

      call Pause 3000 ' clicking Restart or Quit during the Pause gives
      the errors below

      goto [restart]

      [quit]
      close #1
      end

      sub Pause mil
      t=time$("milliseconds")
      while time$("milliseconds") - t < mil
      scan 'SCAN gives 2 errors here:"These handles closed by LB.
      Please add the
      'appropriate Close commands" and "Runtime Error:invalid
      branch label:(restart]
      '(see error.log for more information).
      'Eliminating this SUB and moving this Pause routine to the
      main part does not help.
      'I am concluding that LB has a bug and can't handle this
      coding. Commenting out
      'Scan removes the errors but then I can't Restart or Quit
      during that time.
      wend
      end sub


      --
      No virus found in this outgoing message.
      Checked by AVG Anti-Virus.
      Version: 7.0.308 / Virus Database: 267.9.7 - Release Date: 7/28/2005
    • Alyce Watson
      ... The branch label is not visible inside the sub, so you get an error. (This is documented in the helpfile section on subs and functions.) If you make your
      Message 2 of 2 , Jul 31, 2005
        At 09:03 PM 7/30/2005, you wrote:

        > July 30/05
        >Hi,
        >Can anyone point out the error in the coding below? It prints a set of
        >expanding circles, then pauses for 3 seconds. An error results if
        >Restart or Quit is clicked DURING THE PAUSE, just after the circles have
        >been drawn.

        The branch label is not visible inside the sub, so you get an error. (This
        is documented in the helpfile section on subs and functions.) If you make
        your event handlers subs instead of branch labels, that should fix the
        problem. You could also put your 'pause' code inline, instead of in a sub.
        If I wanted to code a pause, I'd put this code inline:

        calldll #kernel32, "Sleep", 100 as long, ret as void

        Replace the "100" with the number of ms you want.

        -Alyce


        --
        No virus found in this outgoing message.
        Checked by AVG Anti-Virus.
        Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005
      Your message has been successfully submitted and would be delivered to recipients shortly.