Recent

Author Topic: Debbugingproblem?  (Read 6648 times)

T-bear

  • Full Member
  • ***
  • Posts: 160
Debbugingproblem?
« on: November 13, 2010, 04:25:18 pm »
Hi,
When i try to run my program, it compiles the program and starts debbuging. Then after a while the errormessage "Project project1.exe raised exeption class 'External: SIGSEGV'."
When i try to run the executable file this message is shown: "Access violation. Press OK to ignore and risk data corruption. Press Cancel to kill the program."
Anyone who knows why this happens?  %)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Debbugingproblem?
« Reply #1 on: November 13, 2010, 04:35:11 pm »
Because something in your code is causing an Acess Violation, for example accessing a character on a string which does not exist or a variable of a class which was not created.
« Last Edit: November 13, 2010, 04:38:57 pm by typo »

T-bear

  • Full Member
  • ***
  • Posts: 160
Re: Debbugingproblem?
« Reply #2 on: November 13, 2010, 04:53:51 pm »
OK, Everything was OK until i added this code:

Code: [Select]
TKosten = Class (TObject)
    private
      PHoltz: integer;
      PKorn : integer;
      PBrot : integer;
      PGold : integer;
    public
and this:
Code: [Select]
var
  PreisFeller: TKosten;
and this to set the variables:
Code: [Select]
      PreisFeller.PHoltz:=3;
      PreisFeller.PGold :=0;
      PreisFeller.PKorn :=0;
      PreisFeller.PBrot :=0;
Anyone who knows whats wrong with that????!  %)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Debbugingproblem?
« Reply #3 on: November 13, 2010, 04:56:21 pm »
You need to create the instance of the class TKosten before using it.

And Free it after using it.
« Last Edit: November 13, 2010, 04:58:54 pm by typo »

T-bear

  • Full Member
  • ***
  • Posts: 160
Re: Debbugingproblem?
« Reply #4 on: November 13, 2010, 04:58:07 pm »
Instance???

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Debbugingproblem?
« Reply #5 on: November 13, 2010, 05:00:29 pm »
Code: [Select]
PreisFeller := TKosten.Create;
PreisFeller.PHoltz:=3;
PreisFeller.PGold :=0;
PreisFeller.PKorn :=0;
PreisFeller.PBrot :=0;

(...)

PreisFeller.Free;


typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Debbugingproblem?
« Reply #6 on: November 13, 2010, 05:03:41 pm »
Code: [Select]
procedure TForm1.FormCreate(Sender: TObject);
begin
  PreisFeller := TKosten.Create;
end;

procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
  PreisFeller.Free;
end;     

T-bear

  • Full Member
  • ***
  • Posts: 160
Re: Debbugingproblem?
« Reply #7 on: November 13, 2010, 05:08:09 pm »
Thanks  :D Now it works! 

 

TinyPortal © 2005-2018