Hi,
Nice to see you here Svanels- a familiar 'face' as it were.
I'm writing a simple program at the moment and I'm getting annoying EAccessViolation's that I don't know how to fix.
This occurs when I'm trying to read or write to one of my class variables.
Now here's a skeleton of my code:
type
TBaroomForm = class(TForm)
Button1: TBitBtn;
.
.
procedure Button1Click(Sender: TObject);
.
.
private
programs: array [ 1..nButtons-1 ] of String;
procedure readConfigEntries;
.
.
end;
Now these are the lines that cause the violation:
readln( configF, programs[n] );
length( programs[n] );
Apart from this, I tried assigning values directly to programs[index] and this also cause a violation.
First of all, I though that it might be because I declared the variable private however if I couldn't access it for this reason I'd thought the compiler wouldn't even compile it. So I don't think that's the reason.
As I mentioned above length( program[n] ) causes the violation but when I evaluate/modify it I get the correct answer. Also when I modify th string for programs[n] it appears updated but when I evaulet programs[n] again the string is back to the original.
Can anyone help me? I am completely clueless.
As a side question: I have to read in settings from a config file before the main form runs. I've put it in the initialisation part of the unit. Is this a good idea or are there more elegant ways?
Nice to see you here Svanels- a familiar 'face' as it were.
I'm writing a simple program at the moment and I'm getting annoying EAccessViolation's that I don't know how to fix.
This occurs when I'm trying to read or write to one of my class variables.
Now here's a skeleton of my code:
type
TBaroomForm = class(TForm)
Button1: TBitBtn;
.
.
procedure Button1Click(Sender: TObject);
.
.
private
programs: array [ 1..nButtons-1 ] of String;
procedure readConfigEntries;
.
.
end;
Now these are the lines that cause the violation:
readln( configF, programs[n] );
length( programs[n] );
Apart from this, I tried assigning values directly to programs[index] and this also cause a violation.
First of all, I though that it might be because I declared the variable private however if I couldn't access it for this reason I'd thought the compiler wouldn't even compile it. So I don't think that's the reason.
As I mentioned above length( program[n] ) causes the violation but when I evaluate/modify it I get the correct answer. Also when I modify th string for programs[n] it appears updated but when I evaulet programs[n] again the string is back to the original.
Can anyone help me? I am completely clueless.
As a side question: I have to read in settings from a config file before the main form runs. I've put it in the initialisation part of the unit. Is this a good idea or are there more elegant ways?