No announcement yet.

Crazy Exception

  • Filter
  • Time
  • Show
Clear All
new posts

  • Crazy Exception

    I recompiled a large PBWIN7 project to PBWIN9 and came across something strange,
    more stranger then me!

    This line is the original code and uses an interger division that now causes an exception
    in my program when I execute this line of code...

    @ed.wnHeight = MAX&(1, (HIWRD(lParam) - sBarWidth) \ @ed.charHeight + 1)

    ...when I change to a floating point division, it works perfectly again.

    @ed.wnHeight = MAX&(1, (HIWRD(lParam) - sBarWidth) / @ed.charHeight + 1)

    ...and this also works perfectly.

    @ed.wnHeight = MAX&(1, (HIWRD(lParam) - sBarWidth) \ ( @ed.charHeight + 1 ) )

    Stumped and a little bit stupid...
    Last edited by Jules Marchildon; 5 Jul 2009, 07:19 AM.
    Best regards

  • #2
    if @ed.charHeight is zero or extremely small then the integer division will cause a Divide Exception as the reslut will be too large to fit the destination.
    The FP version won't give an exception regardless of the result.

    The third option you add 1 to @ed.charHeight before the divide so you're dividing by 1 instead of zero (or nearly 1 instead of very small).

    Check the value of @ed.charHeight before the divide and see what it is.



    • #3
      Hi Paul,

      Thanks, that is exactly right on! I've been trying to chase down an earlier event that should have preset the value to 15...

      this is Borje's EDM32.INC edit control, I have a modified version of it, I'm stepping through all the mod's right now. This line is in the Size handler, so it iterates 2-3 times and the initial value is 0, ...for the virgin EDM32.INC, the intial value is 15, so I need to see what I did that screwed it up. I was thrown off by the fact compiled with PBWIN7 it supplies an initial value of 15, but not with PBWIN8 and later.


      added later... problem fixed.
      original code included a test... IF @ed.charWidth = 0 OR @ed.charHeight = 0 THEN EXIT FUNCTION
      for some reason I omitted it in my modified version. Thanks for your help Paul !
      Last edited by Jules Marchildon; 5 Jul 2009, 01:00 PM.
      Best regards


      • #4
        Is it something that you can post the code (as-is)? I would like to toss my "" file at it and see what it logs as an error.

        I can raise errors tested for purposely, but looking to test with code that errors "appear" on their own (because I made a mistake in the code)
        Engineer's Motto: If it aint broke take it apart and fix it

        "If at 1st you don't succeed... call it version 1.0"

        "Half of Programming is coding"....."The other 90% is DEBUGGING"

        "Document my code????" .... "WHYYY??? do you think they call it CODE? "