Recent

Author Topic: Error Messages  (Read 813 times)

OC DelGuy

  • New Member
  • *
  • Posts: 30
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.0.10
Date: 07 JUL 2020
FPC Version: 3.2.0
SVN Revision: 63526
x86_64-win64-win32/win64

speter

  • Full Member
  • ***
  • Posts: 185
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. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

OC DelGuy

  • New Member
  • *
  • Posts: 30
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.0.10
Date: 07 JUL 2020
FPC Version: 3.2.0
SVN Revision: 63526
x86_64-win64-win32/win64

wildfire

  • Jr. Member
  • **
  • Posts: 81
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.
Windows 10 64bit version 1809
Laz 2.0.0 FPC 3.0.4

jamie

  • Hero Member
  • *****
  • Posts: 4366
Re: Error Messages
« Reply #4 on: February 28, 2021, 07:16:03 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...

Cosmic Rays ?
The only true wisdom is knowing you know nothing

BlueIcaro

  • Hero Member
  • *****
  • Posts: 645
Re: Error Messages
« Reply #5 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
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

winni

  • Hero Member
  • *****
  • Posts: 2293
Re: Error Messages
« Reply #6 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

  • New Member
  • *
  • Posts: 30
Re: Error Messages
« Reply #7 on: March 01, 2021, 01:07:36 am »
Here's the code. (attached file).
Free Pascal Lazarus Version #: 2.0.10
Date: 07 JUL 2020
FPC Version: 3.2.0
SVN Revision: 63526
x86_64-win64-win32/win64

jamie

  • Hero Member
  • *****
  • Posts: 4366
Re: Error Messages
« Reply #8 on: March 01, 2021, 01:47:35 am »
Well, I see possible issues. Mainly the fact that you are creating a Tpoint from the screen mouse over to the client area and then in your boxes kac-ku-lation you are subtracting numbers like 5 , 10 etc...]

 I believe that should generate a range check error , that is if you have it on! Because that would put the index into the - area if your screenToclient Kac-KU-Latiions are < than 5 or 50.. etc..

 Maybe the formOnClick is getting triggered during startup and you could be getting some really screwy values and then your Blank code gets executed with these -1 values

 Just a thought, really..
The only true wisdom is knowing you know nothing

speter

  • Full Member
  • ***
  • Posts: 185
Re: Error Messages
« Reply #9 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. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

speter

  • Full Member
  • ***
  • Posts: 185
Re: Error Messages
« Reply #10 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. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

speter

  • Full Member
  • ***
  • Posts: 185
Re: Error Messages
« Reply #11 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. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

dseligo

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

speter

  • Full Member
  • ***
  • Posts: 185
Re: Error Messages
« Reply #13 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. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

 

TinyPortal © 2005-2018