Announcement

Collapse
No announcement yet.

Runs Fine In Debugger

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

  • Runs Fine In Debugger

    Greetings All,

    I am writing a program that simulates the operations of a gasoline pump. One of the threads
    monitors the serial port for commands sent from the master control unit located inside of the
    service station. One of the commands received and acted on by my program is a 'Price Change'
    command.

    My program performs as intended (i.e. prices change) only when running under the debugger . . .
    but not when executing directly from the HD or the PowerBasic Compiler window. I searched the
    forum (I was already using #Register None) but can't find anything related to this.

    I thought I'd see if anyone could offer up a general suggestion or two before I posted code.
    (over 1000 lines)

    As always, any and all help is very much appreciated

    Wesley Brown

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

  • #2
    Running under the debugger turns off register variables but, if you're
    already using #REGISTER NONE, that shouldn't make any difference. The
    other major difference is speed: your programs run slower under the
    debugger. This suggests that you might have some sort of synchronization
    issue. I'd also be inclined to suspect something like a missing message
    loop.

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

    Comment


    • #3
      I agree with you Tom that the only other difference should be speed. But, I think that there
      are other differences as well.

      In a fit of aggravation I commented out 98% of the program, leaving only enough for the GUI
      to be displayed. I then began uncommenting sections of code in an attempt to find the
      offending part. Everything was fine until the last line of this section was uncommented:

      Stat(PAddrNum,29) = Val(Mid$(BytesIn,4,1))
      Stat(PAddrNum,30) = Val(Mid$(BytesIn,5,1)) * 1000 + _
      Val(Mid$(BytesIn,6,1)) * 100 + _
      Val(Mid$(BytesIn,7,1)) * 10 + _
      Val(Mid$(BytesIn,8,1))
      Stat (PAddrNum,Stat(PAddrNum,29)) = Stat(PAddrNum,30)

      Additional Info: Stat () As Long
      PAddrNum As Integer
      Dim Stat (16,35)

      I fixed the problem by substituting Temp01 for Stat(PAddrNum,29), and Temp02 for
      Stat(PAddrNum,30) as follows: (note: Temp01 & Temp02 are Integers)

      Temp01 = Val(Mid$(BytesIn,4,1))
      Temp02 = Val(Mid$(BytesIn,5,1)) * 1000 + _
      Val(Mid$(BytesIn,6,1)) * 100 + _
      Val(Mid$(BytesIn,7,1)) * 10 + _
      Val(Mid$(BytesIn,8,1))
      Stat(PAddrNum,Temp01) = Temp02

      This is my very first powerbasic program and so I don't have a clue as to why the original
      code would execute fine from the debugger but not the compiler window. But . . . since I'm
      trying to learn PowerBasic I'd like to know.

      Any ideas and/or constructive criticism would be much appreciated.

      Wesley Brown

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


      [This message has been edited by Wesley Brown (edited January 26, 2001).]

      Comment


      • #4
        Originally posted by Wesley Brown:
        Greetings All,


        My program performs as intended (i.e. prices change) only when running under the debugger . . .
        but not when executing directly from the HD or the PowerBasic Compiler window. I searched the
        forum (I was already using #Register None) but can't find anything related to this.

        I thought I'd see if anyone could offer up a general suggestion or two before I posted code.
        (over 1000 lines)

        As always, any and all help is very much appreciated

        Wesley Brown


        I have had several cases where a program would run only when the #DEBUG ERROR ON option was set.
        Since the debugger turns this option on, it might be related.

        The error has was (almost) always due to bad code on my part. As I remember it, usually due to array out of bounds.
        There was one case however where Dword aligning a UDT fixed the problem. This was strange, because the code was not using pointers to access the UDT.

        --
        Best Regards
        Peter Scheutz




        ------------------
        Best Regards
        Peter Scheutz

        Comment


        • #5
          This has nothing to do with your problem, but...

          Code:
          Temp02 = Val(Mid$(BytesIn,5,1)) * 1000 + _
          Val(Mid$(BytesIn,6,1)) * 100 + _
          Val(Mid$(BytesIn,7,1)) * 10 + _
          Val(Mid$(BytesIn,8,1))
          can be replaced with
          Code:
          Temp02 = VAL (MID$(BytesIn,5,4))

          MCM
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Wesley, it still looks possible that your code is accessing the array outside it's bounds, however, since we have no clues as to the runtime values of those array elements we cannot tell from where we sit.

            Therefore, if you can post the code we can take a look and hopefully locate the exact cause of your problem, simply being able to duplicate your problem. Unless we can do this, we'll likely to just be guessing as causes and solutions which is not very efficient.

            Thanks!




            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment

            Working...
            X