Recent

Author Topic: Error Messages  (Read 1653 times)

OC DelGuy

  • Full Member
  • ***
  • Posts: 121
Error Messages
« on: February 28, 2021, 04:54:54 am »
Ok, So I'm writing this program and these error messages keep popping up:  See pics.

The funny part is that all I do is run it again and sometimes it works!  What the *#&$(@#$??
Let me be plain, I click on the little green arrow (run) and if one of the errors come up, I just click STOP or OK and click the arrow (run) again and and it works.  Actually, it might cause an error again, but eventually it just runs.  And, it runs ok, like it should.
And there's no order in which he errors come up except that the "assembler" window (with the HEX) codes is always after the debugger errors.


Does anyone know what's going on?
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

speter

  • Sr. Member
  • ****
  • Posts: 338
Re: Error Messages
« Reply #1 on: February 28, 2021, 09:20:14 am »
Does anyone know what's going on?
Yes! You have an error in your code.

If you are interested in getting some help, post some code...

cheers
S.
« Last Edit: February 28, 2021, 11:21:11 am by speter »
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

OC DelGuy

  • Full Member
  • ***
  • Posts: 121
Re: Error Messages
« Reply #2 on: February 28, 2021, 06:34:33 pm »
Really?  Why does it work sometimes but errs on other times without changing anything?  Why wouldn't the compiler catch it?

I'll post the code, but I'm on my phone now...

Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

wildfire

  • Full Member
  • ***
  • Posts: 108
Re: Error Messages
« Reply #3 on: February 28, 2021, 06:54:41 pm »
Really?  Why does it work sometimes but errs on other times without changing anything?

You may not have changed anything, but your system isn't in the exact same state between runs.

Quote
Why wouldn't the compiler catch it?

Your code is syntactically correct, but runtime errors can still be there, not a lot a compiler can do about that.
A halo is a mere circle, when does it end?

BlueIcaro

  • Hero Member
  • *****
  • Posts: 791
    • Blog personal
Re: Error Messages
« Reply #4 on: February 28, 2021, 08:42:12 pm »
Hi, sometimes I got the same error, when my program tries to load a Library, and can't find it.

/BlueIcaro

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Error Messages
« Reply #5 on: February 28, 2021, 09:44:19 pm »
Hi!

And sometimes I get the same error if I pour coffee in the CDdrive ....

Hey ! We are not visionaries!
Show us some code.
Without it your problem can't be solved!

Winni

OC DelGuy

  • Full Member
  • ***
  • Posts: 121
Re: Error Messages
« Reply #6 on: March 01, 2021, 01:07:36 am »
Here's the code. (attached file).
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

speter

  • Sr. Member
  • ****
  • Posts: 338
Re: Error Messages
« Reply #7 on: March 01, 2021, 06:10:51 am »
OC DelCuy,

For info, you can "publish" a project, which compresses the correct files into a ZIP file: Project > Publish Project ... (create an new folder to contain the ZIP file; before starting the publish. This will allow other people to open your project in Lazarus on their computers. :)

As it is - with just the .pas file, people will have to recreate your form from scratch and may introduce new issues.

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

speter

  • Sr. Member
  • ****
  • Posts: 338
Re: Error Messages
« Reply #8 on: March 01, 2021, 06:51:23 am »
OC DelGuy,

I've built a form using your .pas file. I made some minor changes (mainly introducing a paintbox component so the form's canvas was not used - this should have to effect).

The first error I encountered was when clicking on the canvas I got a range check error pointing to the following line in procedure blank:
Code: Pascal  [Select][+][-]
  1. Boxes[(d.X-5) div SqSize,(d.Y-50) div SqSize]:=i;
Since boxes are a array [0..21,0..21] you should check the numbers before using them; with something like
Code: Pascal  [Select][+][-]
  1. var ax,ay : integer;
  2. ...
  3.   ax := (d.x-5) div sqSize;
  4.   ay := (d.y-50) div sqSize;
  5.   if (ax in [0..21]) and (ay in [0..21]) then
  6.     boxes[ax,ay] := i
  7.   else
  8.     showmessage(format('There is an error! ax=%d; ay=%d; they should be 0..21',[ax,ay]));
  9.  

I believe this is the error that jamie pointed out earlier.

Note that I made these variables (ax & ay) integers to allow them to be out of the 0..21 range...

Using a paintbox, may mean that you can start drawing the puzzle @ 0,0 which might simplify all this!

cheers
S.

EDIT: the valid range (in pixels) to get [0..21] using your formula is:
  x = -22..620
  y =   23..665         that is very strange!

EDIT 2:
I am going through your code - I haven't found any particular issues so far.
One possible (minor error) is on line 90 of your code:
Code: Pascal  [Select][+][-]
  1.       +IntToStr(y+1+SqSize*(d.Y-5) div SqSize)+')';
everywhere else (I've seen so far) you have "d.y-50"; so the "d.y-5" might be a typo?


« Last Edit: March 01, 2021, 07:49:22 am by speter »
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

speter

  • Sr. Member
  • ****
  • Posts: 338
Re: Error Messages
« Reply #9 on: March 01, 2021, 08:35:33 am »
OC DelGuy,

I've finished going through your code and it seems fine.

I've attached my "version" of your project, in case you are interested in seeing where I changed your code.

cheers
S.

PS: I would recommend turning "debugging" on, while you are developing a project. To do this, go to Project > Project Options > Debugging and check: I/O; Range; Overflow; Stack; and "Verify method calls". Also check "Generate info for the debuggger (slower / increase exe-size)".

PPS: "SIGSEGV" errors generally indicate a variable being accessed which isn't initialised (and/or doesn't have memory allocated); I didn't spot any of those things, so I am at a loss to guess what your error is/was.
« Last Edit: March 01, 2021, 08:38:59 am by speter »
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

dseligo

  • Hero Member
  • *****
  • Posts: 1177
Re: Error Messages
« Reply #10 on: March 01, 2021, 10:34:33 am »
Try to enable option "DisableLoadSymbolsForLibraries" in IDE Options, Debugger, General.

speter

  • Sr. Member
  • ****
  • Posts: 338
Re: Error Messages
« Reply #11 on: March 02, 2021, 02:41:18 am »
OC DelGuy,

I had a bit of a play around, cleaning your code up a bit; see attached project ZIP.

Basically, I moved all the drawing stuff out of your "normal" procedures and moved that code to the paint handler. So, procedures Blank, Both, Down & Across simply call "paintbox1.invalidate" to draw the "board". This makes those procedures mostly redundant but I assume you will be adding more code into them.

I also changed your scaling constant (sqSize) into a variable and recalculate the scale when needed. This means that the "board" size varies if the program's window is resized (or the spin-edits are used to change the board's dimensions).

Hopefully what I've done will be of interest to you and will help you develop your program further. :)

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

 

TinyPortal © 2005-2018